Hi

I understand that it would be hard to implement, as it requires that all
the points are checked, which for a arbitrary plot is not easy.
Though is this not what is already done for the normal autoscale, or have I
misunderstood how the normal autoscale is done?

I would like to have this as a new feature, as it would prove useful for
analysing graphs, especially in scientific research.

Kind regards

Pål





On 3 February 2012 19:56, Eric Firing <efir...@hawaii.edu> wrote:

> On 02/03/2012 06:07 AM, Benjamin Root wrote:
> >
> >
> > On Fri, Feb 3, 2012 at 9:15 AM, Pål Gunnar Ellingsen <paa...@gmail.com
> > <mailto:paa...@gmail.com>> wrote:
> >
> >     Hi
> >
> >     Thank you for trying to help me, though I can't see how aspect is
> going
> >     to help me. As I understand of the documentation, it would require
> >     me to know the
> >     relationship between x and y, which I don't.
> >     I can calculate it, but since it varies between each change in
> xlimits
> >     and different plot, it would be the same as calculating the ylimits.
> >
> >     As for pyplot.xlim(xmin,xmax) (suggested by Ethan Swint), it does
> >     the same as ax.set_xlim() for me.
> >
> >     Below is a sample code that will illustrate the problem.
> >
> >     Regards
> >
> >     Pål
> >
> >     ####### Start code ############
> >
> >     #!/usr/bin/env python
> >     import matplotlib
> >     matplotlib.use('Qt4Agg')   # generate postscript output by default
> >
> >     import matplotlib.pyplot as plt
> >     import numpy as np
> >
> >     # Creating a function to plot
> >     x = np.linspace(-10, 10, 200)
> >     p = np.poly1d([2, 3, 1, 4])
> >     y = p(x) * np.sin(x)
> >
> >     # plotting the full figure
> >     fig = plt.figure()
> >
> >     ax = fig.add_subplot(111)
> >     ax.plot(x, y)
> >     ax.autoscale(tight=True)
> >     plt.title('Full graph. (Press key for next plot)')
> >     plt.draw()
> >
> >     plt.waitforbuttonpress()
> >
> >     # This is how I'm currently doing it
> >     # x limits
> >     xmin = 2
> >     xmax = 6
> >
> >     # Calculating y limits
> >     ymin = y[np.logical_and(xmin < x, x < xmax)].min()
> >     ymax = y[np.logical_and(xmin < x, x < xmax)].max()
> >
> >     # Inserting some room
> >     room = np.maximum(np.abs(ymin * 0.05), np.abs(ymax * 0.05))
> >     ymin = ymin + room * np.sign(ymin)
> >     ymax = ymax + room * np.sign(ymax)
> >
> >     # Setting the limits
> >     ax.set_xlim([xmin, xmax])
> >     ax.set_ylim([ymin, ymax])
> >
> >     plt.title('What I want (Press key for next plot)')
> >     plt.draw()
> >     plt.waitforbuttonpress()
> >
> >     # This is what pyplot does by default if I only set the limits
> >     ax.autoscale(tight=True)
> >     ax.set_xlim([2, 6])
> >
> >     plt.title('What I get if I only use set_xlim (Press key for exit)')
> >     plt.draw()
> >     plt.waitforbuttonpress()
> >     plt.close()
> >
> >     ####### End code ############
> >
> >
> >
> > Ok, I see what you want.  You want the y-limits to automatically change
> > to fit only the data that is displayed for the x-domain you have chosen.
>
> This has never been supported; it would have to be a new option.  I
> suspect it would be quite difficult to get this right in general, even
> though the concept seems simple enough.
>
> Eric
>
> >
> > I have tried some tricks, and I am not sure that it is currently
> > possible.  There might even be some sort of bug at play here because the
> > function ax.update_datalim() does not appear to update the internal data
> > used for autoscaling.  We might have to look into this further.
> >
> > Ben Root
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Try before you buy = See our experts in action!
> > The most comprehensive online learning library for Microsoft developers
> > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> > Metro Style Apps, more. Free future releases when you subscribe now!
> > http://p.sf.net/sfu/learndevnow-dev2
> >
> >
> >
> > _______________________________________________
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to