2012-08-09 134 views
4

使用直方图,有一个简单的内置选项histtype='step'。我如何以同样的风格创作酒吧情节?matplotlib中的未填充条形图

+0

是plt.bar(x,y,color =“None”)你想要什么? – gcalmettes 2012-08-09 21:49:38

+0

不,因为我想消除条相邻的垂直线。 – 2012-08-09 21:52:28

+1

http://stackoverflow.com/questions/11297030/matplotlib-stepped-histogram-with-already-binned-data我在这里找到了答案。这实际上正是我想要做的(使用柱状图作为柱状图),但是我没有找到它,因为我正在寻找关于柱状图的问题。 – 2012-08-10 16:22:19

回答

5

[阅读注释后加入的答案] 设置可选关键字为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)") 

会给: enter image description here

或者使用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)") 

enter image description here

+0

第二张图就是我想他所要求的,这也是我一直在寻找的。 – jimh 2016-09-14 07:00:08