In article <4ca0549d.3060...@hawaii.edu>, Eric Firing <efir...@hawaii.edu> wrote:
> On 09/26/2010 09:43 PM, Fernando Perez wrote: > > Mmh, > > > > On Sun, Sep 26, 2010 at 10:56 PM, Jae-Joon > > Lee<lee.j.j...@gmail.com> wrote: > >> > >> Did you try autoscale_view method? > >> > >> http://matplotlib.sourceforge.net/api/axes_api.html?highlight=autoscale#mat > >> plotlib.axes.Axes.autoscale_view > >> > >> Please post a sample script that reproduces the problem. > >> > > > > I'm wondering if I'm doing something wrong then. Just now I was > > writing some notes about this for a tutorial, and tried this code: > > > > line, = plt.plot([1,2,3], label='my data') > > plt.grid() > > plt.title('My title') > > x = np.linspace(0, 1) > > y = x**2 > > line.set_data(x, y) > > ax = gca() > > ax.autoscale_view() > > plt.draw() > > > > but I get the result shown in the screenshot. Am I misusing > > autoscale_view? As best I can tell from the docstring, I'm making > > correct use of it, but perhaps I'm missing something... > > autoscale_view somewhat defeats the purpose of line.set_data, which is > intentionally minimalist. If you want autoscaling after update, but > don't want to simply clear and plot, then you need to explicitly update > the Axes.dataLim. You can do this using Axes.relim() > prior to calling autoscale_view(). Thank you. That is exactly what I needed. It looks like Axes.get_ybound() will return the min and max displayed y so whenever I add a point I can test if it is within those bounds; if it is not then I can call relim(). That should preserve the efficiency most of the time while still allowing autoscaling and avoiding my having to keep accurate track of what's going on. -- Russell ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users