matplotlib change a Patch in PatchCollection -


patchcollection accepts list of patches , allows me transform / add them canvas @ once. changes 1 of patches after construction of patchcollection object not reflected

for example:

import matplotlib.pyplot plt import matplotlib 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 rectangle @ (1,1), not (2,2) 

i'm looking matplotlib collection group patches can transform them together, want able change individual patches well.

i don't know of collection want, write 1 easily:

import matplotlib.collections mcollections  import matplotlib.pyplot plt import matplotlib mpl   class updatablepatchcollection(mcollections.patchcollection):     def __init__(self, patches, *args, **kwargs):         self.patches = patches         mcollections.patchcollection.__init__(self, patches, *args, **kwargs)      def get_paths(self):         self.set_paths(self.patches)         return self._paths   rect = mpl.patches.rectangle((0,0),1,1)  rect.set_xy((1,1)) collection = updatablepatchcollection([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 rectangle @ (2,2) 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -