From: John H. <jdh...@ac...> - 2005-01-29 20:14:27
|
>>>>> "Alejandro" == Alejandro Weinstein <ale...@ya...> writes: Alejandro> Hi : I hava a plot with mayor and minor ticks and Alejandro> formatters. I want to rotate the labels of both the Alejandro> mayor and minor ticks. I tried with the following code: Alejandro> #... ax.xaxis.set_major_locator(major) Alejandro> ax.xaxis.set_major_formatter(fmt_ma) Alejandro> ax.xaxis.set_minor_locator(minor) Alejandro> ax.xaxis.set_minor_formatter(fmt_mi) labels = Alejandro> ax.get_xticklabels() pylab.set(labels, rotation=30, Alejandro> fontsize=10) Alejandro> However, only the mayor labels are rotated. How can I Alejandro> 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 |