[在阅读评论后添加答案]将可选关键字设置fill=False为条形图:
import matplotlib.pyplot as plt
plt.bar(bins[:5], counts[:5], fill=False, width=60) # <- this is the line
plt.title("Number of nodes with output at timestep")
plt.xlabel("Node count")
plt.ylabel("Timestep (s)")
Run Code Online (Sandbox Code Playgroud)
或者使用plt.plot关键字ls='steps':
plt.plot(bins[-100:], counts[-100:], ls='steps')
plt.title("Number of nodes with output at timestep")
plt.xlabel("Node count")
plt.ylabel("Timestep (s)")
Run Code Online (Sandbox Code Playgroud)
虽然 OP 链接到一个帖子,该帖子回答了一个与直方图步骤图有关的略有不同的问题,但对于经过这里的任何人来说,这是一个解决方案,他们专门试图关闭pyplot.bar条形图中的面部颜色:
import matplotlib.pyplot as plt
import numpy as np
# create x coords for the bar plot
x = np.linspace(1, 10, 10)
# cook up some random bar heights -- exact results may vary :-P
y = np.random.randn(10)
z = np.random.randn(10) * 2
# plot bars with face color off
plt.bar(x-0.2, y, width=0.4, edgecolor='purple', color='None')
plt.bar(x+0.2, z, width=0.4, edgecolor='darkorange', color='None')
plt.show()
Run Code Online (Sandbox Code Playgroud)
请注意,杆边缘具有可设定的matplotlib.lines.Line2D属性,例如linewidth,linestyle,alpha,等等:
plt.bar(x-0.2, y, width=0.4, edgecolor='purple', color='None',
linewidth=0.75, linestyle='--')
plt.bar(x+0.2, z, width=0.4, edgecolor='darkorange', color='None',
linewidth=1.5, linestyle='-.')
plt.show()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12556 次 |
| 最近记录: |