I make a number of patches like so -
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)
And originally I was just putting them straight onto my axis like this -
self.plotAxes.add_artist(node.shape)
self.plotAxes.add_artist(node.brushShape)
That worked fine. But now I want to put them into a PatchCollection and put that PatchCollection onto the axis. However, when I do that, all of my shapes are just blue. I don't understand how just putting into a collection is changing the color somehow. Can anyone help me out on what I need to be doing to keep the color values that I input as the faceColor for the patches?
The new code is -
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)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…