Making room for tick labels

Not to pile on the "auto-adjust to make labels fit" bandwagon, but
I've been following the FAQ on adjusting the subplot locations to make
room for too-long tick labels:

   http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels

and have found that the FAQ code isn't very robust.

For example, if I interactively change the size of the plotting window
so the ylabels touch the left hand side of the window, stretching it
right again pushes the labels and the subplots too far to the right
(see attached 'auto_subplot_adjust.toofar.png').

If I make the window too narrow so the figure itself shrinks too much,
it starts to raise 'ValueError: left cannot be >= right' exceptions,
and then really shrinks the plot even more (see attached
'auto_subplot_adjust.leftright.png').

Any suggestions for making this more robust?

     Justin

auto_subplot_adjust.toofar.png

auto_subplot_adjust.leftright.png

I made the FAQ entry code a little more general (and hopefully more robust) a while ago. I don't know if it takes care of the problem you're talking about, though.

I posted it to the matplotlib-devel mailing list here:

http://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg05628.html

You're welcome to use it, and if it makes more sense than the FAQ entry, whoever does the FAQ is welcome to include it in the FAQ.

Jason

···

On 9/29/10 12:49 PM, Justin McCann wrote:

Not to pile on the "auto-adjust to make labels fit" bandwagon, but
I've been following the FAQ on adjusting the subplot locations to make
room for too-long tick labels:

    http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels

and have found that the FAQ code isn't very robust.

For example, if I interactively change the size of the plotting window
so the ylabels touch the left hand side of the window, stretching it
right again pushes the labels and the subplots too far to the right
(see attached 'auto_subplot_adjust.toofar.png').

If I make the window too narrow so the figure itself shrinks too much,
it starts to raise 'ValueError: left cannot be>= right' exceptions,
and then really shrinks the plot even more (see attached
'auto_subplot_adjust.leftright.png').

Any suggestions for making this more robust?

--
Jason Grout

Thanks, Jason. I tried it out, and it has the same issues.

···

On Wed, Sep 29, 2010 at 9:58 PM, Jason Grout <jason-sage@...2130...> wrote:

...
I made the FAQ entry code a little more general (and hopefully more
robust) a while ago. I don't know if it takes care of the problem
you're talking about, though.

I posted it to the matplotlib-devel mailing list here:

[matplotlib-devel] Automatically make room for tick labels FAQ entry