【发布时间】:2016-02-23 10:16:52
【问题描述】:
我想旋转自动生成的绘图的 x 轴标签,以防止标签重叠:
有人建议我matplotlib.pyplot.setp 值得一看,但我不知道如何将它与自动生成的标签结合使用。
如何旋转这些标签?
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")
【问题讨论】:
标签: python matplotlib axis overlap labels