【发布时间】: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 版本是什么?
-
我相信matplotlib版本是1.4.3。
-
可以通过
python -c 'import matplotlib; print(matplotlib.__version__)'验证
标签: python python-2.7 matplotlib