Ste*_*ing 9 python patch colors matplotlib
我制作了许多补丁 -
node.shape = RegularPolygon((node.posX, node.posY),
6,
radius = node.radius,
edgecolor = 'none',
facecolor = node.fillColor,
zorder = node.zorder)
node.brushShape = RegularPolygon((node.posX, node.posY),
6,
node.radius * 0.8,
linewidth = 3,
edgecolor = (1,1,1),
facecolor = 'none',
zorder = node.zorder)
Run Code Online (Sandbox Code Playgroud)
最初我只是把它们直接放在我的轴上 - 就像这样 -
self.plotAxes.add_artist(node.shape)
self.plotAxes.add_artist(node.brushShape)
Run Code Online (Sandbox Code Playgroud)
这工作得很好.但是现在我想将它们放入PatchCollection并将PatchCollection放到轴上.然而,当我这样做时,我的所有形状都只是蓝色.我不明白只是投入一个集合是如何以某种方式改变颜色.任何人都可以帮我解决我需要做什么来保持我输入的颜色值作为补丁的faceColor?
新代码是 -
node.shape = RegularPolygon((node.posX, node.posY),
6,
radius = node.radius,
edgecolor = 'none',
facecolor = node.fillColor,
zorder = node.zorder)
node.brushShape = RegularPolygon((node.posX, node.posY),
6,
node.radius * 0.8,
linewidth = 3,
edgecolor = (1,1,1),
facecolor = 'none',
zorder = node.zorder)
self.patches.append(node.shape)
self.patches.append(node.brushShape)
self.p = PatchCollection(self.patches)
self.plotAxes.add_collection(self.p)
Run Code Online (Sandbox Code Playgroud)
tac*_*ell 17
self.p = PatchCollection(self.patches, match_original=True)
Run Code Online (Sandbox Code Playgroud)
默认情况下,补丁集合会覆盖给定的颜色(doc),以便能够应用颜色映射,循环颜色等.这是一个collection级别功能(以及散射图后面的代码的功能).