Overlapping labels

Hi, I am having a bit of trouble with labels on the x-axis

    > overlapping and going off-screen. I am using a DayLocator
    > and a DateFormatter and once I plot more than 10 data
    > points or so, the labels start printing over each other. If
    > I set the formatter to print the tick labels on several
    > lines, my x-label gets pushed off-screen. Is there a way to
    > get the text to scale itself to my graph so that I don't
    > get any overlap?

matplotlib doesn't try to be too smart, so the tick sizes, locations,
etc, don't scale themselves. But it makes up for its rather braindead
layout algorithms by making it relatively easy to configure all of the
properties manually to avoid the kind of problem you describe. See,
for example, http://matplotlib.sourceforge.net/faq.html#TEXTOVERLAP

Eg, use "subplots_adjust" to move the bottom of the subplots higher if
the ticklabels are running off the bottom (version 0.82 or later)


If you are using the API, subplots_adjust is a figure.Figure method.

You can also change the rotation and size of the xticklabels to help
prevent overlap. In pylab,

  xticks(fontsize=9, rotation=45)

or in the API

  for label in ax.get_xticklabels():

of if you prefer the "set" style configuration

  from matplotlib.artist import setp
  setp(ax.get_xticklabels(), fontsize=9, rotation=45)

The moral of the story is that by controlling the subplot axes
properties, and the ticklabel font properties, you can manually layout
the Axes more or less as you wish.