## Re: [Matplotlib-users] moving a patch

 Re: [Matplotlib-users] moving a patch From: John Hunter - 2006-05-27 17:37:58 ```>>>>> "Jochen" == Jochen Voss writes: Jochen> By the way: does anybody know how to move a patch in Jochen> matplotlib? set_data works for lines, but what works for Jochen> patches? This should be easier, but here's an example with a regular polygon -- it is quite easy to generalize this to any patch... Use the blit techniques described on the animation wiki if you want to make this significantly more efficient from matplotlib.patches import RegularPolygon from pylab import figure, show, nx class MyPoly(RegularPolygon): def __init__(self, *args, **kwargs): RegularPolygon.__init__(self, *args, **kwargs) self.offsetx = 0 self.offsety = 0 self.x, self.y = map(nx.array, zip(*RegularPolygon.get_verts(self))) def get_verts(self): x = self.x + self.offsetx y = self.y + self.offsety return zip(x, y) poly = MyPoly(xy=(1,1), numVertices=6, radius=5) fig = figure() ax = fig.add_subplot(111, xlim=(-100, 100), ylim=(-100, 100), autoscale_on=False) ax.add_patch(poly) def start(event): fig.canvas.mpl_disconnect(start.cid) randn = nx.mlab.randn for i in range(200): poly.offsetx += 2*randn() poly.offsety += 2*randn() fig.canvas.draw() start.cid = fig.canvas.mpl_connect('draw_event', start) show() ```

 [Matplotlib-users] moving a patch From: Jochen Voss - 2006-05-22 15:11:42 Attachments: Message as HTML ```Hello, I am trying to generate a short movie using matplotlib. The core of my code looks like for i in range(1,len(t)): U0,U1x,U1y,H1 =3D list(sig[i,:]) for x in arange(0,1.001,0.05): for y in arange(0,1.001,0.05): xx,yy=3Dtrace(U0,U1x,U1y,H1,x,y) ts[(x,y)].set_data(xx,yy) for j in range(0,nobs): tr[j].center =3D (obs[i,2*j],obs[i,2*j+1]) savefig("f%04d.png"%i) where the entries of the dictionary 'ts' are lines and the entries of the dictionary 'tr' a patches (circles). Moving the lines around with set_data works quite fine, but moving the patches by setting 'center' does not. My question: how do I move a patch? Many thanks, Jochen --=20 http://seehuhn.de/ ```
 Re: [Matplotlib-users] moving a patch From: Alan G Isaac - 2006-05-26 16:18:53 ```How are you turning your PNGs into an animation? Thanks, Alan Isaac PS I know about http://www.pymolwiki.org/index.php/Category%3ASoftware_Movies ```
 Re: [Matplotlib-users] moving a patch From: Andrew Straw - 2006-05-26 18:42:24 ```I use the following on Debian Sarge linux (both x86_64 and i686, although I hope/think it would work on any architecture and hopefully any linux distro): "ffmpeg -hq -b 8000 -f mpeg2video -r 30 -i frame%03d.png movie.mpeg" You may now skip the rest of this email, which is an uncalled-for venting-of-frustration. Unfortunately, it seems bazillions of software companies think they can make bazillions of dollars by releasing yet another codec encumbered by more-or-less (but usually more) restrictive licensing conditions, leaving only lowest-common denominator codecs available for those of us who prefer to work without such restrictions. I sought long and hard to do something better than the above, but I can say this about the above command: * it produces movies that play in Windows (including PowerPoint, which isn't a given, even if it plays in Windows Media Player -- c'mon Microsoft, this is 2006, we should be able to play movies in our presentations), Mac OS X, and linux (Debian sarge, amd64 and i386, at least) * it seems to work with a standard Debian setup, and doesn't require using DLLs imported from some Windows system to to the encoding * it seems very fragile -- changing the frame rate or the codec usually breaks one of the above points * mpeg2 is probably also burdened by some licensing restrictions which I'm unaware of * on some Windows boxes/programs, white backgrounds get displayed as gray for some reason Wishing that in 2006 we as a human race could come up with a better, open video format, but willing to accept even minor improvements to the above script, Andrew Alan G Isaac wrote: >How are you turning your PNGs into an animation? > >Thanks, >Alan Isaac > >PS I know about >http://www.pymolwiki.org/index.php/Category%3ASoftware_Movies > > ```
 Re[2]: [Matplotlib-users] moving a patch From: Alan G Isaac - 2006-05-27 00:38:43 ```On Fri, 26 May 2006, Andrew Straw apparently wrote: > ffmpeg -hq -b 8000 -f mpeg2video -r 30 -i frame%03d.png movie.mpeg" > * it seems very fragile -- changing the frame rate or the > codec usually breaks one of the above points OK. Thanks for the information and warning. Did you experiment with MNG, or is support just not there yet? (And will the next PIL be supporting MNG?) Cheers, Alan Isaac ```
 Re: [Matplotlib-users] moving a patch From: Jochen Voss - 2006-05-27 13:20:49 Attachments: Message as HTML ```Hi Alan, On Fri, May 26, 2006 at 12:26:07PM -0400, Alan G Isaac wrote: > How are you turning your PNGs into an animation? Sorry about the slow answer. I just used mencoder: mencoder 'mf://oc/*.png'; -mf type=3Dpng:fps=3D12 -ovc lavc -lavcopts vc= odec=3Dmpeg4 -o ocean.avi All the best, Jochen --=20 http://seehuhn.de/ ```
 Re: [Matplotlib-users] moving a patch From: Jochen Voss - 2006-05-27 13:26:15 Attachments: Message as HTML ```Hi Andrew, On Fri, May 26, 2006 at 11:42:07AM -0700, Andrew Straw wrote: > Wishing that in 2006 we as a human race could come up with a better,=20 > open video format, ... I think most of the problems is caused by software patents. It is just not safe for Linux distributions etc. to integrate video encoders, so all the solutions which exist are hidden away somewhere, are not well integrated into the system, and also not too well tested. By the way: does anybody know how to move a patch in matplotlib? set_data works for lines, but what works for patches? Many thanks, Jochen --=20 http://seehuhn.de/ ```
 Re: [Matplotlib-users] moving a patch From: John Hunter - 2006-05-27 17:37:58 ```>>>>> "Jochen" == Jochen Voss writes: Jochen> By the way: does anybody know how to move a patch in Jochen> matplotlib? set_data works for lines, but what works for Jochen> patches? This should be easier, but here's an example with a regular polygon -- it is quite easy to generalize this to any patch... Use the blit techniques described on the animation wiki if you want to make this significantly more efficient from matplotlib.patches import RegularPolygon from pylab import figure, show, nx class MyPoly(RegularPolygon): def __init__(self, *args, **kwargs): RegularPolygon.__init__(self, *args, **kwargs) self.offsetx = 0 self.offsety = 0 self.x, self.y = map(nx.array, zip(*RegularPolygon.get_verts(self))) def get_verts(self): x = self.x + self.offsetx y = self.y + self.offsety return zip(x, y) poly = MyPoly(xy=(1,1), numVertices=6, radius=5) fig = figure() ax = fig.add_subplot(111, xlim=(-100, 100), ylim=(-100, 100), autoscale_on=False) ax.add_patch(poly) def start(event): fig.canvas.mpl_disconnect(start.cid) randn = nx.mlab.randn for i in range(200): poly.offsetx += 2*randn() poly.offsety += 2*randn() fig.canvas.draw() start.cid = fig.canvas.mpl_connect('draw_event', start) show() ```