我正在使用 matplotlib.pyplot 模块绘制直方图,我想知道如何强制 y 轴标签只显示整数(例如 0、1、2、3 等)而不是小数(例如 0.、0.5 , 1., 1.5, 2. 等)。
我正在查看指导说明,怀疑答案在matplotlib.pyplot.ylim附近,但到目前为止,我只能找到设置最小和最大 y 轴值的东西。
def doMakeChart(item, x):
if len(x)==1:
return
filename = "C:\Users\me\maxbyte3\charts\\"
bins=logspace(0.1, 10, 100)
plt.hist(x, bins=bins, facecolor='green', alpha=0.75)
plt.gca().set_xscale("log")
plt.xlabel('Size (Bytes)')
plt.ylabel('Count')
plt.suptitle(r'Normal Distribution for Set of Files')
plt.title('Reference PUID: %s' % item)
plt.grid(True)
plt.savefig(filename + item + '.png')
plt.clf()