2
我遇到了matplotlib一个非常奇怪的问题。绘制一些要点如下:matplotlib日志规模导致缺少点
当我切换到在y轴的对数刻度,一些观点是不连接:
这是一个错误?我错过了什么吗?代码如下。将日志比例线注释掉以查看第一个图。
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(111)
x = [1.0, 2.0, 3.01, 4.01, 5.01, 6.01, 7.04, 8.04, 9.04, 10.05,
11.05, 12.09, 13.17, 14.18, 15.73, 16.74, 17.74, 18.9, 19.91,
20.94, 22.05, 23.15, 24.33, 25.48, 26.51, 27.58, 28.86, 29.93,
30.93, 32.23, 33.25, 34.26, 35.27, 36.29, 37.33, 38.35, 39.36,
40.37, 41.37]
y = [552427, 464338, 446687, 201960, 227238, 265140, 148903, 134851,
172234, 120263, 115385, 100671, 164542, 171176, 28, 356, 0, 0,
195, 313, 9, 0, 132, 0, 249, 242, 81, 217, 159, 140, 203, 215,
171, 141, 154, 114, 99, 97, 97]
ax1.plot(x, y, c='b', marker='o')
ax1.set_yscale('log')
plt.ylim((-50000, 600000))
plt.show()
啊,有意思。我想知道是否有一些解决方法 – jterrace 2012-08-15 15:23:05
我想解决方法将非常依赖于你想要显示这些点的位置。 – mgilson 2012-08-15 15:25:52
啊,对,因为在一个对数标度上,0最终会处于y轴的无限底部。将它们设置为1应该适用于我的情况,谢谢! – jterrace 2012-08-15 15:28:24