PatchCollection
accepts a list of Patch
es and allows me to transform / add them to a canvas all at once. But changes to the one of the Patch
es after the construction of the PatchCollection
object are not reflected
for example:
import matplotlib.pyplot as plt
import matplotlib as mpl
rect = mpl.patches.Rectangle((0,0),1,1)
rect.set_xy((1,1))
collection = mpl.collections.PatchCollection([rect])
rect.set_xy((2,2))
ax = plt.figure(None).gca()
ax.set_xlim(0,5)
ax.set_ylim(0,5)
ax.add_artist(collection)
plt.show() #shows a rectangle at (1,1), not (2,2)
I'm looking for a matplotlib collection that will group patches just so I can transform them together, but I want to be able to change the individual patches as well.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…