Animate scatter plots

hi, I tried your script, commenting/uncommenting the backend line, but I still get:
[cohen@...1986... ~]$ ipython -pylab MACROS/animation.py
---------------------------------------------------------------------------

AttributeError Traceback (most recent call last)

/home/cohen/MACROS/animation.py in <module>()
   274 p.show()
   275
--> 276 t = test()
   277
   278

/home/cohen/MACROS/animation.py in __init__(self)
   270
   271 # cid = p.gcf().canvas.mpl_connect('idle_event', self.update)
--> 272 wx.GetApp().Bind(wx.EVT_IDLE, self.update)
   273
   274 p.show()

AttributeError: 'NoneType' object has no attribute 'Bind'
WARNING: Failure executing file: <MACROS/animation.py>

I am using MPL revision 6440.
cheers,
Johann

Eric Bruning wrote:

Hi Eric,

I've looked through the latest examples as well as google and the list
archives, and am still at a loss -- can anyone point me to an example of
how to animate a scatter plot?
      
I've attached a somewhat unpolished but functional example that shows
time-synchronized animation of multiple scatter plots. It uses the wx
backend explicitly, due to some issues with the idle event handling.

The collection returned by scatter() lacks anything akin to a set_data method.
      
Yup, you want this instead:
collection.set_offsets(xy)
collection.set_array(s)

-Eric
  ------------------------------------------------------------------------

-------------------------------------------------------------------------

This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

···

On Fri, Nov 21, 2008 at 11:19 AM, Eric Jonas <jonas@...1166...> wrote:

Strange, strange. iPython is apparently having some effect here: I tried
ipython -pylab animation.py
and I got a figure with the initial plot, but nothing further
happened. After closing the plot, I typed
run animation.py
at the ipython prompt, and saw the initial plot, erasure, and
animation that I expected. Can you try running with a plain
python animation.py

I've attached a new version of the script with some changes suggested
offline by Ryan May - he was seeing platform or wx-specific behavior
related to event handling. All bugs remaining are mine :slight_smile:

-Eric

animation.py (10.9 KB)

···

On Sun, Nov 23, 2008 at 6:20 PM, Cohen-Tanugi Johann <cohen@...2407...> wrote:

hi, I tried your script, commenting/uncommenting the backend line, but I
still get:
[cohen@...1986... ~]$ ipython -pylab MACROS/animation.py

---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)

/home/cohen/MACROS/animation.py in <module>()
  274 p.show()
  275
--> 276 t = test()
  277
  278

/home/cohen/MACROS/animation.py in __init__(self)
  270
  271 # cid = p.gcf().canvas.mpl_connect('idle_event',
self.update)
--> 272 wx.GetApp().Bind(wx.EVT_IDLE, self.update)
  273
  274 p.show()

AttributeError: 'NoneType' object has no attribute 'Bind'
WARNING: Failure executing file: <MACROS/animation.py>

I am using MPL revision 6440.
cheers,
Johann

Eric Bruning wrote:

Hi Eric,

On Fri, Nov 21, 2008 at 11:19 AM, Eric Jonas <jonas@...1166...> wrote:

I've looked through the latest examples as well as google and the list
archives, and am still at a loss -- can anyone point me to an example
of
how to animate a scatter plot?

I've attached a somewhat unpolished but functional example that shows
time-synchronized animation of multiple scatter plots. It uses the wx
backend explicitly, due to some issues with the idle event handling.

The collection returned by scatter() lacks anything akin to a set_data
method.

Yup, you want this instead:
collection.set_offsets(xy)
collection.set_array(s)

-Eric
------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

indeed it works with python now, provided I uncomment the wxAgg setting in the script.
best,
Johann

Eric Bruning wrote:

···

Strange, strange. iPython is apparently having some effect here: I tried
ipython -pylab animation.py
and I got a figure with the initial plot, but nothing further
happened. After closing the plot, I typed
run animation.py
at the ipython prompt, and saw the initial plot, erasure, and
animation that I expected. Can you try running with a plain
python animation.py

I've attached a new version of the script with some changes suggested
offline by Ryan May - he was seeing platform or wx-specific behavior
related to event handling. All bugs remaining are mine :slight_smile:

-Eric

On Sun, Nov 23, 2008 at 6:20 PM, Cohen-Tanugi Johann > <cohen@...2407...> wrote:
  

hi, I tried your script, commenting/uncommenting the backend line, but I
still get:
[cohen@...1986... ~]$ ipython -pylab MACROS/animation.py

---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)

/home/cohen/MACROS/animation.py in <module>()
  274 p.show()
  275
--> 276 t = test()
  277
  278

/home/cohen/MACROS/animation.py in __init__(self)
  270
  271 # cid = p.gcf().canvas.mpl_connect('idle_event',
self.update)
--> 272 wx.GetApp().Bind(wx.EVT_IDLE, self.update)
  273
  274 p.show()

AttributeError: 'NoneType' object has no attribute 'Bind'
WARNING: Failure executing file: <MACROS/animation.py>

I am using MPL revision 6440.
cheers,
Johann

Eric Bruning wrote:
      

Hi Eric,

On Fri, Nov 21, 2008 at 11:19 AM, Eric Jonas <jonas@...1166...> wrote:

I've looked through the latest examples as well as google and the list
archives, and am still at a loss -- can anyone point me to an example
of
how to animate a scatter plot?

I've attached a somewhat unpolished but functional example that shows
time-synchronized animation of multiple scatter plots. It uses the wx
backend explicitly, due to some issues with the idle event handling.

The collection returned by scatter() lacks anything akin to a set_data
method.

Yup, you want this instead:
collection.set_offsets(xy)
collection.set_array(s)

-Eric
------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users