title: Vertical xtick labels on top, not bottom
body: <p>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 on top of the axis, not below.</p>
  
  <p>This command can plot vertical labels on bottom:</p>
  
  <pre><code>pylab.imshow(confusion_matrix)
  pylab.xticks(..., rotation='vertical')
  </code></pre>
  
  <p>and this command can plot horizontal labels on top without rotation:</p>
  
  <pre><code>pylab.matshow(confusion_matrix)
  </code></pre>
  
  <p>but I cannot find anything that does both. The following command does not work.</p>
  
  <pre><code>pylab.matshow(confusion_matrix)
  pylab.xticks(..., rotation='vertical')
  </code></pre>
  
  <p>Can you suggest a way to plot a confusion matrix with xticks on top of the axis with vertical rotation? Thank you.</p>
  
  <p>EDIT</p>
  
  <p>Thank you, Mark, for your help. It got me on the right track by inspecting the tick properties more closely. The only difference with your answer and my desired answer is applying that idea to an AxesImage, not a plot. After investigation, here is the answer:</p>
  
  <pre><code>im = pylab.matshow(confusion_matrix)
  for label in im.axes.xaxis.get_ticklabels():
      label.set_rotation(90)
  im.figure.show()
  </code></pre>
  
  <p>To those reading... don't forget about show()! I forgot that I needed to refresh the figure. See output below.</p>
  
  <p><a href="http://up.stevetjoa.com/rotate_ticklabels.png">Confusion matrix with vertical labels. http://up.stevetjoa.com/rotate_ticklabels.png</a></p>