Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## [Matplotlib-users] padding axis limits automatically?

 [Matplotlib-users] padding axis limits automatically? From: Skipper Seabold - 2012-03-30 18:48:17 ```There is probably a simple answer to this, but I don't see it. How can I pad the axis limits automatically? For instance, in the below example, the x axis limits are the data points and the y limit is close. I want to have a function that pads the axis limit at least, by say, 10% of the range of x past the last data point without having to take my x values and calculate some sensible x limit. Is this possible? import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) x = [1,2,3] y = [8125, 9754, 10855] ax.plot(x,y,marker='D',ms=12) plt.show() ```

 [Matplotlib-users] padding axis limits automatically? From: Skipper Seabold - 2012-03-30 18:48:17 ```There is probably a simple answer to this, but I don't see it. How can I pad the axis limits automatically? For instance, in the below example, the x axis limits are the data points and the y limit is close. I want to have a function that pads the axis limit at least, by say, 10% of the range of x past the last data point without having to take my x values and calculate some sensible x limit. Is this possible? import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) x = [1,2,3] y = [8125, 9754, 10855] ax.plot(x,y,marker='D',ms=12) plt.show() ```
 Re: [Matplotlib-users] padding axis limits automatically? From: Tony Yu - 2012-03-30 20:26:52 Attachments: Message as HTML ```On Fri, Mar 30, 2012 at 2:47 PM, Skipper Seabold wrote: > There is probably a simple answer to this, but I don't see it. How can > I pad the axis limits automatically? For instance, in the below > example, the x axis limits are the data points and the y limit is > close. I want to have a function that pads the axis limit at least, by > say, 10% of the range of x past the last data point without having to > take my x values and calculate some sensible x limit. Is this > possible? > > > import matplotlib.pyplot as plt > fig = plt.figure() > ax = fig.add_subplot(111) > x = [1,2,3] > y = [8125, 9754, 10855] > ax.plot(x,y,marker='D',ms=12) > plt.show() > > A similar issuecame up recently on the list: http://old.nabble.com/Why-are-bars,-errorbars...-clipped-td33525497.html I posted a snippet of codethere. Ben Root also mentioned `padx` and `pady` parameters, but I was not able to find them. Best, -Tony ```
 Re: [Matplotlib-users] padding axis limits automatically? From: Eric Firing - 2012-03-30 20:40:33 ```On 03/30/2012 08:47 AM, Skipper Seabold wrote: > There is probably a simple answer to this, but I don't see it. How can > I pad the axis limits automatically? For instance, in the below > example, the x axis limits are the data points and the y limit is > close. I want to have a function that pads the axis limit at least, by > say, 10% of the range of x past the last data point without having to > take my x values and calculate some sensible x limit. Is this > possible? Does the margins() function or method do what you want? http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.margins http://matplotlib.sourceforge.net/api/axes_api.html?highlight=margins#matplotlib.axes.Axes.margins Eric > > > import matplotlib.pyplot as plt > fig = plt.figure() > ax = fig.add_subplot(111) > x = [1,2,3] > y = [8125, 9754, 10855] > ax.plot(x,y,marker='D',ms=12) > plt.show() > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ```
 Re: [Matplotlib-users] padding axis limits automatically? From: Tony Yu - 2012-03-30 21:45:34 Attachments: Message as HTML ```On Fri, Mar 30, 2012 at 4:40 PM, Eric Firing wrote: > On 03/30/2012 08:47 AM, Skipper Seabold wrote: > > There is probably a simple answer to this, but I don't see it. How can > > I pad the axis limits automatically? For instance, in the below > > example, the x axis limits are the data points and the y limit is > > close. I want to have a function that pads the axis limit at least, by > > say, 10% of the range of x past the last data point without having to > > take my x values and calculate some sensible x limit. Is this > > possible? > > Does the margins() function or method do what you want? > > > http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.margins > > > http://matplotlib.sourceforge.net/api/axes_api.html?highlight=margins#matplotlib.axes.Axes.margins > > Eric > > Thanks for the tip, Eric. I'm continually surprised by all the useful stuff that's nestled in the corners of matplotlib. Hmm, it looks like `margins` doesn't support log scales, though. Maybe I'll submit a PR on this later. Best, -Tony ```
 Re: [Matplotlib-users] padding axis limits automatically? From: Skipper Seabold - 2012-03-30 21:52:34 ```On Fri, Mar 30, 2012 at 5:45 PM, Tony Yu wrote: > > On Fri, Mar 30, 2012 at 4:40 PM, Eric Firing wrote: >> >> On 03/30/2012 08:47 AM, Skipper Seabold wrote: >> > There is probably a simple answer to this, but I don't see it. How can >> > I pad the axis limits automatically? For instance, in the below >> > example, the x axis limits are the data points and the y limit is >> > close. I want to have a function that pads the axis limit at least, by >> > say, 10% of the range of x past the last data point without having to >> > take my x values and calculate some sensible x limit. Is this >> > possible? >> >> Does the margins() function or method do what you want? >> >> >> http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.margins >> >> >> http://matplotlib.sourceforge.net/api/axes_api.html?highlight=margins#matplotlib.axes.Axes.margins >> >> Eric >> > Thanks for the tip, Eric. I'm continually surprised by all the useful stuff > that's nestled in the corners of matplotlib. > Indeed. Both solutions are nice. I've never noticed margins before, even though this is a common issue for me. The documentation isn't all the clear, what exactly to do with it, but set_xmargin and set_ymargin cleared that up. Thanks. Skipper ```