I'm looking for a way to alternate my x-axis tick labels across two levels. My labels now are:
A B C D
What I want would be
A   C
  B   D
But I can't seem to find how on google/docs/SO.
Thanks a lot!
I'm looking for a way to alternate my x-axis tick labels across two levels. My labels now are:
A B C D
What I want would be
A   C
  B   D
But I can't seem to find how on google/docs/SO.
Thanks a lot!
You can use minor ticks (defined via set_minor_locator and set_minor_formatter). Then you can shift e.g. all major ticks using tick_params:
import pylab as pl
from matplotlib.ticker import FixedLocator, FormatStrFormatter
pl.plot(range(100))
pl.axes().xaxis.set_major_locator(FixedLocator(range(0, 100, 10)))
pl.axes().xaxis.set_minor_locator(FixedLocator(range(5, 100, 10)))
pl.axes().xaxis.set_minor_formatter(FormatStrFormatter("%d"))
pl.axes().tick_params(which='major', pad=20, axis='x')

But be careful with FixedLocator: To avoid generating major ticks twice (once as major and once as minor ticks) I chose fixed tick locations instead of using a MultipleLocator. You'll need to adjust these tick locations to your data and window size.
(Idea borrowed from here.)