title: How can I rotate the auto-generated x-axis labels of a matplotlib plot?
body: <p>I want to rotate the automatically-generated x-axis labels of my plot in order to prevent the labels from overlapping:</p>
  
  <p><img src="https://i.imgur.com/M8qoULB.png" alt=""></p>
  
  <p>I have been advised that <code>matplotlib.pyplot.setp</code> is worth a look, but I don't know how to use it in conjunction with labels that are generated automatically.</p>
  
  <p>How can I rotate these labels?</p>
  
  <pre><code>x = [element[0] for element in eventDuplicates]
  y = [element[1] for element in eventDuplicates]
  figure = matplotlib.pyplot.figure()
  figure.suptitle("event duplicates", fontsize = 20)
  matplotlib.pyplot.scatter(x, y, s = 1, alpha = 1)
  axes = matplotlib.pyplot.gca()
  axes.yaxis.set_major_formatter(FormatStrFormatter("%.0f"))
  axes.xaxis.set_major_formatter(FormatStrFormatter("%.0f"))
  axes.set_xlim(left = 0)
  #axes.set_ylim(bottom = 0)
  #matplotlib.pyplot.setp(rotation = 90) # &lt;--- insert magic here
  matplotlib.pyplot.xlabel("run numbers")
  matplotlib.pyplot.ylabel("event numbers")
  matplotlib.pyplot.savefig("diagnostic_event_duplicates_scatter.png")
  </code></pre>