I have a matplotlib.PatchCollection
that I want to add to a plot. But I also have Text and other Patches I am adding straight onto the plot. So it looks like this:
node.shape = RegularPolygon((node.posX, node.posY),
6,
radius = node.radius,
edgecolor = 'none',
facecolor = node.fillColor,
zorder = node.zorder)
self.patches.append(node.shape)
self.p = PatchCollection(self.patches, edgecolor = 'none', match_original=True )
self.plotAxes.add_collection(self.p)
#Two previously instantiated patches (they are visible)
self.plotAxes.add_artist(selectionRect)
self.plotAxes.add_artist(brushShape)
self.plotCanvas.draw()
I want my Patches in the collection to be drawn first and then the selctionRect
and brushShape
to be drawn afterwards because they can overlap the Patches in the collection. If they do, they should be visible. However, my plot always shows the Patches in the collection as if they've been drawn last. How can I get around this? Any help is appreciated.
Edit: One thing that appears to work is to keep 2 PatchCollections. However, when I do this, it seems that I can never set the visibilities to false. Does the PatchCollection
set the reset the values or something?