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) 
                self.p = PatchCollection(self.patches, match_original=True) 
By default patch collection over-rides the given color (doc) for the purposes of being able to apply a color map, cycle colors, etc.  This is a collection level feature (and what powers the code behind scatter plot).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With