Matplotlib yaxis 范围显示使用绝对值而不是偏移值? [英] Matplotlib yaxis range display using absolute values rather than offset values?

查看:36
本文介绍了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":

推荐答案

set useOffset to False:

set useOffset to False:

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

这篇关于Matplotlib yaxis 范围显示使用绝对值而不是偏移值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆