My code is very simple:
values = [-2071238, -2071241, -2071240, -2071242, -2071244, -2071239, -2071221, -2071194, -2071224, -2071240, -2071244, -2071241, -2071240, -2071241, -2071237, -2071223, -2071205, -2071225, -2071238]
indx = [0.0, 20.0, 40.0, 60.0, 80.0, 100.0, 120.0, 140.0, 160.0, 180.0, 200.0, 220.0, 240.0, 260.0, 280.0, 300.0, 320.0, 340.0, 360.0]
plt.scatter(indx, values)
#rendering
plt.xlabel("Axis 1")
plt.ylabel("Axis 2")
title = "All"
plt.title(title)
plt.savefig(title + ".png")
plt.show()
然而,得到的图形如下:
很明显,每个点的y值都不太好。
我是做错了什么还是忘记了什么?
ax.ticklabel_format
的调用useOffset=False
将会失败。在这种情况下,你需要明确指定不是日期轴的轴,使用ax.ticklabel_format(axis="y", useOffset=False)
(这里,x是日期轴)。原因是轴参数默认设置为"both",否则ax.ticklabel_format
将会抛出 "This method only works with the ScalarFormatter" 的异常。 - MrCC