I want to rotate the automatically-generated x-axis labels of my plot in order to prevent the labels from overlapping:
I have been advised that matplotlib.pyplot.setp
is worth a look, but I don't know how to use it in conjunction with labels that are generated automatically.
How can I rotate these labels?
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) # <--- insert magic here
matplotlib.pyplot.xlabel("run numbers")
matplotlib.pyplot.ylabel("event numbers")
matplotlib.pyplot.savefig("diagnostic_event_duplicates_scatter.png")