【问题标题】:Force pyplot to show actual axis values [duplicate]强制pyplot显示实际轴值[重复]
【发布时间】:2013-10-15 15:01:31
【问题描述】:

我正在使用 Python 和 Pyplot 来制作绘图。绘图的 y 轴是自动生成的,并且工作正常。

但是,如果范围很小,y 轴将产生如下值:

0.00005,  
0.00010,  
0.00015,  
0.00020,  
0.00025,  
0.00030, 

然后在轴的顶部,会说:

+1.543e-1

我希望它只明确显示值:

0.15435  
0.15440  
0.15445  
0.15450  
0.15455  
0.15460  

有人能告诉我怎么做吗?

【问题讨论】:

标签: python matplotlib plot


【解决方案1】:

好吧,我想我找到了完整的解决方案:

这是重现您的问题的快速图:

plot((0.15435,0.15440,0.15445,0.15450,0.15455,0.15460),(0.15435,0.15440,0.15445,0.15450,0.15455,0.15460))

以下代码(类似于here 所示的方式)应该按照您的意愿调整代码:

y_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
gca().yaxis.set_major_formatter(y_formatter)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-07
    • 2012-02-09
    • 2014-02-19
    • 2023-03-07
    • 2011-05-07
    • 2020-08-22
    • 2015-02-14
    • 1970-01-01
    相关资源
    最近更新 更多