gpt4 book ai didi

python - Matplotlib yaxis范围显示使用绝对值而不是偏移值?

转载 作者:IT老高 更新时间:2023-10-28 22:14:19 27 4
gpt4 key购买 nike

我有以下范围的 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”,有时不是(取决于数据范围?)。

“奇怪地”绘制:
Plotted Badly

“正确”绘制:
Plotted Correctly

最佳答案

将 useOffset 设置为 False:

ax = plt.gca()
ax.ticklabel_format(useOffset=False)

关于python - Matplotlib yaxis范围显示使用绝对值而不是偏移值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9303728/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com