我有以下范围的numpy数据(usec时间戳的增量):
array([ 4.312, 4.317, 4.316, 4.32 , 4.316, 4.316, 4.319, 4.317,
4.317, 4.316, 4.318, 4.316, 4.318, 4.316, 4.318, 4.317,
4.317, 4.317, 4.316, 4.317, 4.318, 4.316, 4.318, 4.316,
4.318, 4.316, 4.317, 4.317, 4.318, 4.316, 4.317, 4.317,
4.317, 4.317, 4.317, 4.316, 4.319, 4.315, 4.319, 4.315,
4.319, 4.315, 4.316, 4.319, 4.317, 4.317, 4.317, 4.318,
4.315, 4.317, 4.317, 4.317, 4.319, 4.314, 4.32 , 4.315,
4.317, 4.318, 4.315, 4.318, 4.317, 4.317, 4.317, 4.316,
4.317, 4.318, 4.317, 4.317, 4.317, 4.315, 4.319, 4.317,
4.315, 4.319, 4.316, 4.318, 4.318, 4.315, 4.318, 4.317,
4.317, 4.321])
当我用matplotlib.pyplot绘图时:
import matplotlib.pyplot as plt
plt.plot( deltas )
plt.show()
我得到以下情节。为什么Y轴按比例缩放?如何将Y轴标记为数据,而不是数据的偏移量?有时情节是“+ 4.nnn”,有时它不是(取决于数据范围?)。
绘制“奇怪”:
“正确”绘制:
答案 0 :(得分:40)
将useOffset设置为False:
ax = plt.gca()
ax.ticklabel_format(useOffset=False)
答案 1 :(得分:9)
您也可以使用
ax = plt.gca()
ax.set_yticklabels(ax.get_yticks())
虽然我更喜欢@ HYRY的答案。
答案 2 :(得分:6)
This answer建议禁用偏移作为全局设置,这对我有用:
matplotlib.rcParams['axes.formatter.useoffset'] = False