I want to plot a confusion matrix using Pylab. The class labels along the horizontal axis are long, so I want to plot them rotated vertically. However, I also want to plot them
Reading your post, and trying by myself, I found one very simple way of setting the ticks on top on the axes:
pylab.gca().tick_top()
Cheers!
If I understand you correctly, this will get you close. You might have to 'pad' your labels out with spaces to move them off the xaxis line.
from matplotlib import pylab
pylab.plot([0, 6], [0, 6])
pylab.xticks([1,2,3,4,5,6],('one','two','three','four','five','six'),rotation='vertical',verticalalignment='bottom')
EDIT IN RESPONSE TO COMMENT
If you want them rotated vertical on the top x-axis, try this:
pylab.plot([0, 6], [0, 6])
pylab.xticks([1,2,3,4,5,6],('one','two','three','four','five','six'))
for tick in pylab.gca().xaxis.iter_ticks():
tick[0].label2On = True
tick[0].label1On = False
tick[0].label2.set_rotation('vertical')