Matplotlib yaxis范围显示使用绝对值而不是偏移值吗? [英] Matplotlib yaxis range display using absolute values rather than offset values?
本文介绍了Matplotlib yaxis范围显示使用绝对值而不是偏移值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下范围的numpy数据(usec时间戳的增量):
I have the following range of numpy data (deltas of usec timestamps):
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进行绘图时:
When I plot with matplotlib.pyplot:
import matplotlib.pyplot as plt
plt.plot( deltas )
plt.show()
我得到以下情节.为什么以这种方式缩放Y轴?如何获得Y轴作为数据的标签,而不是数据的偏移量?有时情节是"+ 4.nnn",有时则不是(取决于数据范围?).
I get the following plot. Why is the Y-axis being scaled that way? How can I get the Y-axis to be labeled as the data, not an offset of the data? Sometimes the plot is the "+4.nnn" sometimes it isn't (depending on the data range?).
奇怪地"绘制:
Plotted "strangely":
正确"绘制:
Plotted "correctly":
推荐答案
将useOffset设置为False:
set useOffset to False:
ax = plt.gca()
ax.ticklabel_format(useOffset=False)
这篇关于Matplotlib yaxis范围显示使用绝对值而不是偏移值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文