animated plot with autoscaling

I would like to extend the animated plot paradigm to an application
where I need to autoscale the vertical axis each time the plot is
updated. Any suggestions as to how to do so? I assume I need to tell
the axis to autoscale, then draw the axis' artist. However, I am not
sure how to do these things, I'm having trouble finding the
appropriate methods in the matplotlib class documentation.
Thanks,
Glenn

Hello Glenn

Do you refer to a special example?
Maybe the following helps you.

···

------------------------------------------------------------------------------
from pylab import *

ion()
ax = subplot(111)
# ... some plotting
ax.relim() # reset intern limits of the current axes
ax.autoscale_view() # reset axes limits

ioff()
show()
--------------------------------------------------------------------------------------

Good luck,
Matthias

On Friday 25 April 2008 08:01:24 G Jones wrote:

I would like to extend the animated plot paradigm to an application
where I need to autoscale the vertical axis each time the plot is
updated. Any suggestions as to how to do so? I assume I need to tell
the axis to autoscale, then draw the axis' artist. However, I am not
sure how to do these things, I'm having trouble finding the
appropriate methods in the matplotlib class documentation.
Thanks,
Glenn

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/java
one _______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hello,
Thank you for the suggestion. However, I am refering to the
canvas.restore_region, draw_artist, blit, gui_repaint sort of
animation.
Glenn

···

On Thu, Apr 24, 2008 at 11:13 PM, Matthias Michler <MatthiasMichler@...361...> wrote:

Hello Glenn

Do you refer to a special example?
Maybe the following helps you.
------------------------------------------------------------------------------
from pylab import *

ion()
ax = subplot(111)
# ... some plotting
ax.relim() # reset intern limits of the current axes
ax.autoscale_view() # reset axes limits

ioff()
show()
--------------------------------------------------------------------------------------

Good luck,
Matthias

On Friday 25 April 2008 08:01:24 G Jones wrote:
> I would like to extend the animated plot paradigm to an application
> where I need to autoscale the vertical axis each time the plot is
> updated. Any suggestions as to how to do so? I assume I need to tell
> the axis to autoscale, then draw the axis' artist. However, I am not
> sure how to do these things, I'm having trouble finding the
> appropriate methods in the matplotlib class documentation.
> Thanks,
> Glenn
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/java
>one _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

His suggestion is still correct -- after you update the line data and
before you call draw_artist, you can acll relim and autoscale_view as
Mattias suggested. However, this will not always do what you want,
because it will autoscale both the x and the y. In animated plots,
often you are just updating the ydata an want to manually control the
xlim and autoscale the ylim (eg strip charting). In that case, I
would do :

        self.ax1.relim()
        self.ax1.set_ylim(*self.ax1.yaxis.major.locator.autoscale())

JDH

···

On Fri, Apr 25, 2008 at 1:19 AM, G Jones <glenn.caltech@...287...> wrote:

Hello,
Thank you for the suggestion. However, I am refering to the
canvas.restore_region, draw_artist, blit, gui_repaint sort of
animation.
Glenn

Hi,
Thank you for pointing that out, that does indeed do what I want
mostly. However, while the data is autoscaled to the plot, the values
on the y axis are not updated and they remain at their original
values. I suspect this is because I am not giving a command to redraw
the axes. How would I go about doing that? I think I need to blit a
larger bbox that encompasses the axes as well, but I'm not sure how to
get that.
By the way, I found that self.ax1.autoscale_view(scalex=False, scaley
= True) seems to autoscale just the y axis and seems clearer than the
set_ylim code suggested below.
Thanks again,
Glenn

···

On 4/26/08, John Hunter <jdh2358@...287...> wrote:

On Fri, Apr 25, 2008 at 1:19 AM, G Jones <glenn.caltech@...287...> wrote:
> Hello,
> Thank you for the suggestion. However, I am refering to the
> canvas.restore_region, draw_artist, blit, gui_repaint sort of
> animation.
> Glenn

His suggestion is still correct -- after you update the line data and
before you call draw_artist, you can acll relim and autoscale_view as
Mattias suggested. However, this will not always do what you want,
because it will autoscale both the x and the y. In animated plots,
often you are just updating the ydata an want to manually control the
xlim and autoscale the ylim (eg strip charting). In that case, I
would do :

        self.ax1.relim()
        self.ax1.set_ylim(*self.ax1.yaxis.major.locator.autoscale())

  JDH