【问题标题】:matplotlib stepfilled histogram breaks at the value 10^-1 on xubuntumatplotlib 步进填充直方图在 xubuntu 上的值 10^-1 处中断
【发布时间】:2016-04-25 18:35:03
【问题描述】:

为什么当代码通过 python 运行时,图形似乎在 y 轴上的 10^-1 处分解?(下面的代码)

from pylab import *

bins = [+0.000e+00,+1.000e+00,+2.000e+00,+3.000e+00,+4.000e+00,+5.000e+00]
wght = [[+3.000e-02,+7.0e-02,+3.0e-01,+5.0e-01,+8.0e-01]]

hist([ bins[:-1] for i in range(len(wght)) ], bins=bins, weights=wght,histtype="stepfilled", log=True )

ylim(bottom=0.01); ylim(top=1.0)

savefig("./output.pdf")

它应该是什么样子:

实际的样子:

我目前在 Xubuntu 14.04 上运行 python 2.7,这个错误发生在许多直方图上。出于某种原因,当在 Windows 上打开并通过 Python(x,y) 运行时,我们得到了第一个直方图(它应该是什么样子)但是当我在 Xubuntu 上转到 python 时,我尝试运行的所有图表都与这个类似都有问题在 y 轴上的 10^-1 处。(它实际上是什么样子)我可以用这段代码做什么来确保它在我想运行的任何 python 版本上输出第一张 gyazo 图片?

【问题讨论】:

  • 输出与 python 2.7 和 matplotlib 1.4.2 相同,但与 python 2.7 和 matplotlib 1.3.1 不同(xubuntu 14.04 / 可信赖)。 Windows 上的 matplotlib 版本是什么?
  • 之前一直有这个问题,github.com/matplotlib/matplotlib/issues/196
  • 我相信matplotlib版本是1.4.3。
  • 可以通过python -c 'import matplotlib; print(matplotlib.__version__)'验证

标签: python python-2.7 matplotlib


【解决方案1】:

此行为存在于旧版本中,建议安装新版本。

输出与 python 2.7 和 matplotlib 1.4.2 (debian / jessie) 相同,但与 python 2.7 和 matplotlib 1.3.1 (xubuntu 14.04 / trusty) 不同。

可以查看matplotlib的版本

python -c 'import matplotlib; print(matplotlib.__version__)'

【讨论】:

  • 谢谢!您知道在使用旧版本时是否有任何已知的解决方法?
猜你喜欢
  • 1970-01-01
  • 2018-10-14
  • 2013-05-30
  • 2020-08-11
  • 1970-01-01
  • 2014-03-17
  • 1970-01-01
  • 2020-05-20
  • 2019-10-31
相关资源
最近更新 更多