我做了很多这样的补丁 -
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.plotAxes.add_artist(node.shape)
self.plotAxes.add_artist(node.brushShape)
那工作得很好。但现在我想将它们放入 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)