From: Brian G. <ell...@gm...> - 2011-03-02 06:27:44
|
Hi, I am trying to do a simple animation examples similar to the one here: http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc But it does not work. I have tried with different backends, plain python, within ipython. I am using ipython 0.10 and matplotlib 0.99.3 from EPD. I have used this approach in the past, but no luck this time. If I add a show() early on, the first plot shows OK, but it sits and waits until I close the plot window before moving on. Any ideas? Cheers, Brian -- Brian E. Granger, Ph.D. Assistant Professor of Physics Cal Poly State University, San Luis Obispo bgr...@ca... ell...@gm... |
From: John H. <jd...@gm...> - 2011-03-02 13:45:24
|
On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger <ell...@gm...> wrote: > Hi, > > I am trying to do a simple animation examples similar to the one here: > > http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc > > But it does not work. I have tried with different backends, plain > python, within ipython. I am using ipython 0.10 and matplotlib 0.99.3 > from EPD. I have used this approach in the past, but no luck this > time. If I add a show() early on, the first plot shows OK, but it > sits and waits until I close the plot window before moving on. Any > ideas? If you are running mpl from the development tree on github, I suggest you use the new animations API, which hides much of the complexity. See https://github.com/matplotlib/matplotlib/tree/master/examples/animation If you are running a released mpl, you can simply drop the animation.py file into your PYTHONPATH and use it directly https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py Hope this helps, JDH |
From: Benjamin R. <ben...@ou...> - 2011-03-02 18:23:01
|
On Wed, Mar 2, 2011 at 7:44 AM, John Hunter <jd...@gm...> wrote: > On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger <ell...@gm...> > wrote: > > Hi, > > > > I am trying to do a simple animation examples similar to the one here: > > > > > http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc > > > > But it does not work. I have tried with different backends, plain > > python, within ipython. I am using ipython 0.10 and matplotlib 0.99.3 > > from EPD. I have used this approach in the past, but no luck this > > time. If I add a show() early on, the first plot shows OK, but it > > sits and waits until I close the plot window before moving on. Any > > ideas? > > If you are running mpl from the development tree on github, I suggest > you use the new animations API, which hides much of the complexity. > See > > https://github.com/matplotlib/matplotlib/tree/master/examples/animation > > If you are running a released mpl, you can simply drop the > animation.py file into your PYTHONPATH and use it directly > > > https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py > > Hope this helps, > JDH > > I don't think that is necessarily true. If I remember correctly, Ryan May introduced some other API changes (I think they made it to the 1.0.x branch) in order to facilitate his animations. Ben Root |
From: Benjamin R. <ben...@ou...> - 2011-03-02 14:31:06
|
On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger <ell...@gm...> wrote: > Hi, > > I am trying to do a simple animation examples similar to the one here: > > > http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc > > But it does not work. I have tried with different backends, plain > python, within ipython. I am using ipython 0.10 and matplotlib 0.99.3 > from EPD. I have used this approach in the past, but no luck this > time. If I add a show() early on, the first plot shows OK, but it > sits and waits until I close the plot window before moving on. Any > ideas? > > Cheers, > > Brian > > Animations can be a very fickle thing in matplotlib. Everything has to be perfect for it to work properly. Are you able to run that first example on that page? Can you include a self-contained version of your code that reproduces your problem? Ben Root |
From: Brian G. <ell...@gm...> - 2011-03-02 18:44:05
|
Is the old method (just using draw/set_xdata, etc.) not supported? I am working with a student and I want to keep is dead simple. Brian On Wed, Mar 2, 2011 at 10:22 AM, Benjamin Root <ben...@ou...> wrote: > > > On Wed, Mar 2, 2011 at 7:44 AM, John Hunter <jd...@gm...> wrote: >> >> On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger <ell...@gm...> >> wrote: >> > Hi, >> > >> > I am trying to do a simple animation examples similar to the one here: >> > >> > >> > http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc >> > >> > But it does not work. I have tried with different backends, plain >> > python, within ipython. I am using ipython 0.10 and matplotlib 0.99.3 >> > from EPD. I have used this approach in the past, but no luck this >> > time. If I add a show() early on, the first plot shows OK, but it >> > sits and waits until I close the plot window before moving on. Any >> > ideas? >> >> If you are running mpl from the development tree on github, I suggest >> you use the new animations API, which hides much of the complexity. >> See >> >> https://github.com/matplotlib/matplotlib/tree/master/examples/animation >> >> If you are running a released mpl, you can simply drop the >> animation.py file into your PYTHONPATH and use it directly >> >> >> https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py >> >> Hope this helps, >> JDH >> > > I don't think that is necessarily true. If I remember correctly, Ryan May > introduced some other API changes (I think they made it to the 1.0.x branch) > in order to facilitate his animations. > > Ben Root > > -- Brian E. Granger, Ph.D. Assistant Professor of Physics Cal Poly State University, San Luis Obispo bgr...@ca... ell...@gm... |
From: Benjamin R. <ben...@ou...> - 2011-03-02 21:50:50
|
On Wed, Mar 2, 2011 at 12:43 PM, Brian Granger <ell...@gm...> wrote: > Is the old method (just using draw/set_xdata, etc.) not supported? I > am working with a student and I want to keep is dead simple. > > Brian > > Those functions are still supported. I can run the example on that page without issues using the development version of mpl, GTKAgg, and python 2.6. There might be some other possibilities to consider. For example, if you are working in the pylab mode and you have multiple figures and/or axes, the draw() command might be going to the wrong figure because draw() operates on whichever figure would be returned by gcf() (I believe). Ben Root |
From: Ryan M. <rm...@gm...> - 2011-03-02 21:56:54
|
On Wed, Mar 2, 2011 at 12:43 PM, Brian Granger <ell...@gm...> wrote: > Is the old method (just using draw/set_xdata, etc.) not supported? I > am working with a student and I want to keep is dead simple. The old method is subject to the problems you're encountering now because you're working outside the GUI's event loop. The new method was created to be "dead simple" and yet work reliably. If there's some kind of unintuitive/hard part of the new animation API, I'd love to know about it. Ryan > > Brian > > On Wed, Mar 2, 2011 at 10:22 AM, Benjamin Root <ben...@ou...> wrote: >> >> >> On Wed, Mar 2, 2011 at 7:44 AM, John Hunter <jd...@gm...> wrote: >>> >>> On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger <ell...@gm...> >>> wrote: >>> > Hi, >>> > >>> > I am trying to do a simple animation examples similar to the one here: >>> > >>> > >>> > http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc >>> > >>> > But it does not work. I have tried with different backends, plain >>> > python, within ipython. I am using ipython 0.10 and matplotlib 0.99.3 >>> > from EPD. I have used this approach in the past, but no luck this >>> > time. If I add a show() early on, the first plot shows OK, but it >>> > sits and waits until I close the plot window before moving on. Any >>> > ideas? >>> >>> If you are running mpl from the development tree on github, I suggest >>> you use the new animations API, which hides much of the complexity. >>> See >>> >>> https://github.com/matplotlib/matplotlib/tree/master/examples/animation >>> >>> If you are running a released mpl, you can simply drop the >>> animation.py file into your PYTHONPATH and use it directly >>> >>> >>> https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py >>> >>> Hope this helps, >>> JDH >>> >> >> I don't think that is necessarily true. If I remember correctly, Ryan May >> introduced some other API changes (I think they made it to the 1.0.x branch) >> in order to facilitate his animations. >> >> Ben Root >> >> > > > > -- > Brian E. Granger, Ph.D. > Assistant Professor of Physics > Cal Poly State University, San Luis Obispo > bgr...@ca... > ell...@gm... > > ------------------------------------------------------------------------------ > Free Software Download: Index, Search & Analyze Logs and other IT data in > Real-Time with Splunk. Collect, index and harness all the fast moving IT data > generated by your applications, servers and devices whether physical, virtual > or in the cloud. Deliver compliance at lower cost and gain new business > insights. http://p.sf.net/sfu/splunk-dev2dev > _______________________________________________ > Matplotlib-devel mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel > -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma |
From: Brian G. <ell...@gm...> - 2011-03-02 22:43:50
|
>> Is the old method (just using draw/set_xdata, etc.) not supported? I >> am working with a student and I want to keep is dead simple. > > The old method is subject to the problems you're encountering now > because you're working outside the GUI's event loop. The new method > was created to be "dead simple" and yet work reliably. If there's some > kind of unintuitive/hard part of the new animation API, I'd love to > know about it. The main issue I have is that I am working with undergraduate students who have no experience installing things from scratch. In this context I am stuck with whatever is in EPD. Currently EPD is at 1.0.1, which does not have animation. Will this file "just work" with 1.0.1 or 0.99.3? I don't have any aversion to using animation.py, I just need to be able to use it within a stock recent EPD. Cheers, Brian > Ryan > >> >> Brian >> >> On Wed, Mar 2, 2011 at 10:22 AM, Benjamin Root <ben...@ou...> wrote: >>> >>> >>> On Wed, Mar 2, 2011 at 7:44 AM, John Hunter <jd...@gm...> wrote: >>>> >>>> On Wed, Mar 2, 2011 at 12:27 AM, Brian Granger <ell...@gm...> >>>> wrote: >>>> > Hi, >>>> > >>>> > I am trying to do a simple animation examples similar to the one here: >>>> > >>>> > >>>> > http://www.scipy.org/Cookbook/Matplotlib/Animations#head-e50abcca4333d3d76b3f2bb66ef00f15c6b4dbbc >>>> > >>>> > But it does not work. I have tried with different backends, plain >>>> > python, within ipython. I am using ipython 0.10 and matplotlib 0.99.3 >>>> > from EPD. I have used this approach in the past, but no luck this >>>> > time. If I add a show() early on, the first plot shows OK, but it >>>> > sits and waits until I close the plot window before moving on. Any >>>> > ideas? >>>> >>>> If you are running mpl from the development tree on github, I suggest >>>> you use the new animations API, which hides much of the complexity. >>>> See >>>> >>>> https://github.com/matplotlib/matplotlib/tree/master/examples/animation >>>> >>>> If you are running a released mpl, you can simply drop the >>>> animation.py file into your PYTHONPATH and use it directly >>>> >>>> >>>> https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/animation.py >>>> >>>> Hope this helps, >>>> JDH >>>> >>> >>> I don't think that is necessarily true. If I remember correctly, Ryan May >>> introduced some other API changes (I think they made it to the 1.0.x branch) >>> in order to facilitate his animations. >>> >>> Ben Root >>> >>> >> >> >> >> -- >> Brian E. Granger, Ph.D. >> Assistant Professor of Physics >> Cal Poly State University, San Luis Obispo >> bgr...@ca... >> ell...@gm... >> >> ------------------------------------------------------------------------------ >> Free Software Download: Index, Search & Analyze Logs and other IT data in >> Real-Time with Splunk. Collect, index and harness all the fast moving IT data >> generated by your applications, servers and devices whether physical, virtual >> or in the cloud. Deliver compliance at lower cost and gain new business >> insights. http://p.sf.net/sfu/splunk-dev2dev >> _______________________________________________ >> Matplotlib-devel mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel >> > > > > -- > Ryan May > Graduate Research Assistant > School of Meteorology > University of Oklahoma > -- Brian E. Granger, Ph.D. Assistant Professor of Physics Cal Poly State University, San Luis Obispo bgr...@ca... ell...@gm... |
From: John H. <jd...@gm...> - 2011-03-02 22:50:27
Attachments:
double_pendulum_animated.py
|
On Wed, Mar 2, 2011 at 4:43 PM, Brian Granger <ellisonb > The main issue I have is that I am working with undergraduate students > who have no experience installing things from scratch. In this > context I am stuck with whatever is in EPD. Currently EPD is at > 1.0.1, which does not have animation. Will this file "just work" with > 1.0.1 or 0.99.3? I don't have any aversion to using animation.py, I > just need to be able to use it within a stock recent EPD. With EPD and mpl 1.0.1, the new API should work if you drop animation.py into your site-packages, eg as mpl_animation.py,and import it like import mpl_animation as animation Then later they can just change this to import matplotlib.animation as animation Let us know if you have any troubles with this approach. I've attached a double pendulum example which is fun, and illustrates how to animate multiple objects, a line instance for the pendulum and a text instance for the time counter. JDH |
From: Ryan M. <rm...@gm...> - 2011-03-02 23:00:41
|
On Wed, Mar 2, 2011 at 4:50 PM, John Hunter <jd...@gm...> wrote: > On Wed, Mar 2, 2011 at 4:43 PM, Brian Granger <ellisonb >> The main issue I have is that I am working with undergraduate students >> who have no experience installing things from scratch. In this >> context I am stuck with whatever is in EPD. Currently EPD is at >> 1.0.1, which does not have animation. Will this file "just work" with >> 1.0.1 or 0.99.3? I don't have any aversion to using animation.py, I >> just need to be able to use it within a stock recent EPD. > > With EPD and mpl 1.0.1, the new API should work if you drop > animation.py into your site-packages, eg as mpl_animation.py,and > import it like > > import mpl_animation as animation > > Then later they can just change this to > > import matplotlib.animation as animation > > Let us know if you have any troubles with this approach. > > I've attached a double pendulum example which is fun, and illustrates > how to animate multiple objects, a line instance for the pendulum and > a text instance for the time counter. I trust you're going to check in that completely awesome example. Brian, if you're still adverse to using an external module (I understand), 1.0.1 does have the new timer infrastructure that will work with the event loop properly. Here's your example converted to taht: from pylab import * def update_line(line): line.set_ydata(sin(x+line.counter/10.0)) # update the data line.counter += 1 draw() if line.counter > 200: return False x = arange(0,2*pi,0.01) # x-array line, = plot(x,sin(x)) line.counter = 0 # Store the counter on the line object # Get the current figure and get it to create a new timer. fig = gcf() timer = fig.canvas.new_timer(interval=50) timer.add_callback(update_line, line) timer.start() show() Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma |
From: Fernando P. <fpe...@gm...> - 2011-03-03 03:16:00
|
On Wed, Mar 2, 2011 at 3:00 PM, Ryan May <rm...@gm...> wrote: > I trust you're going to check in that completely awesome example. BTW, that completely awesome example was just demoed in front of a standing-room only audience at the SIAM CSE 11 meeting :) The matplotlib talk (delivered by yours truly b/c John couldn't make it) was very well received, the interest in Python here is remarkable. Cheers, f |