答案 0 :(得分:1)
我不认为只有plt.bar
可以实现这一点,但你可以通过组合plt.bar
来获取阴影区域,plt.step
来获取大纲。
例如:
import numpy as np
import matplotlib.pyplot as plt
fig,ax = plt.subplots(1)
# Generate some random data
hist1,bins1 = np.histogram(np.random.normal(2,1,1000),bins=np.arange(-2,8,0.5))
hist2,bins2 = np.histogram(np.random.normal(4,1,1000),bins=np.arange(0,10,0.5))
# 'step' draws the lines, 'bar' fills them
ax.step(bins1[:-1],hist1,'k',linestyle='-',linewidth=2,where='post')
ax.bar(bins1[:-1],hist1,width=0.5,linewidth=0,facecolor='k',alpha=0.3)
ax.step(bins2[:-1],hist2,'k',linestyle='--',linewidth=2,where='post')
ax.bar(bins2[:-1],hist2,width=0.5,linewidth=0,facecolor='k',alpha=0.1)
plt.show()