On Fri, Mar 30, 2012 at 4:40 PM, Eric Firing <efiring@hawaii.edu> 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