如何删除关闭步骤直方图路径的底线?


import numpy as np
import matplotlib.pyplot as plt
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)
fig = plt.figure()
ax = fig.add_subplot(111)
n, bins, patches = ax.hist(x, 50, normed=1, histtype='step')
plt.ylim(-.005, plt.ylim()[1])
plt.show()更新:已报告,现在已修复:
发布于 2013-05-31 18:04:40
最简单的方法就是把它画成你自己:
import numpy as np
import matplotlib.pyplot as plt
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)
fig = plt.figure()
ax = fig.add_subplot(111)
bins, edges = np.histogram(x, 50, normed=1)
ax.step(edges[:-1], bins, where='post')
plt.ylim(-.005, plt.ylim()[1])
plt.show()请参阅文档或matplotlib中的Step函数以了解where=post。因为直方图返回[left_edege_0, left_edge_1, ..., left_edge_(n-1), right_edge_(n-1)] (参见文档),所以需要将最后一个条目从边缘剪掉。
这已被认为是一种倒退,并将在至少1.3内固定下来。相关公关:https://github.com/matplotlib/matplotlib/pull/2113
https://stackoverflow.com/questions/16862501
复制相似问题