如何在matplotlib中向条形图添加垂直线

时间:2017-08-22 12:28:34

标签: python pandas matplotlib

我有以下代码:

ax = df30_pivoted.plot(kind='bar', figsize=(30,20), linewidth=5)
plt.xticks(rotation='vertical')
plt.tick_params(labelsize=20)
plt.xlabel('session_date', fontsize=20)
plt.grid(True)
plt.title('', fontdict={'fontsize':60})
legend = ax.legend(loc=0, ncol=1, bbox_to_anchor=(0,1,1), fancybox=True, shadow=False, title='variations', prop={'size':45})


xposition = c12
for xc in xposition:
    ax.axvline(x=xc, color='r', linewidth=4)
plt.setp(legend.get_title(), fontsize='30')

plt.show()

我希望上面的代码放置垂直线,其中x轴上的索引与c12中的索引相同,c12是类型为datetime64[ns]的pandas系列,但结果条形图没有垂直线:

enter image description here

0 个答案:

没有答案
相关问题