PatchCollection
接受一个Patch
列表,并允许我一次性将它们转换/添加到画布中。但是,在构建PatchCollection
对象后对其中一个Patch
进行更改不会反映在画布上。例如:
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)
我正在寻找一个matplotlib集合,可以将补丁组合在一起以便一起进行转换,但我也想能够更改单个补丁。