Hi : I hava a plot with mayor and minor ticks and
> formatters. I want to rotate the labels of both the
> mayor and minor ticks. I tried with the following code:
> #... ax.xaxis.set_major_locator(major)
> ax.xaxis.set_major_formatter(fmt_ma)
> ax.xaxis.set_minor_locator(minor)
> ax.xaxis.set_minor_formatter(fmt_mi) labels =
> ax.get_xticklabels() pylab.set(labels, rotation=30,
> fontsize=10)
> However, only the mayor labels are rotated. How can I
> rotate both the major and minor labels?
You can access the minor tick labels and minor tick labels by getting
a list of the minor ticks and accessing the label attribute
minlabels = [tick.label1 for tick in ax.xaxis.get_minor_ticks()]
The tick attributes are
tick1line : a Line2D instance
tick2line : a Line2D instance
gridline : a Line2D instance
label1 : an Text instance
label2 : an Text instance
gridOn : a boolean which determines whether to draw the tickline
tick1On : a boolean which determines whether to draw the 1st tickline
(left for xtick and bottom for yticks)
tick2On : a boolean which determines whether to draw the 2nd tickline
(left for xtick and bottom for yticks)
label1On : a boolean which determines whether to draw tick label
label2On : a boolean which determines whether to draw tick label
which is also documented at
http://matplotlib.sf.net/matplotlib.axis.html#Tick . The difference
between label1 and label2 is for left and right labeling for yticks,
and top and bottom labeling for xticks.
You can then call set on the list of labels to set the rotation,
etc...
Hope this helps.
JDH