您如何在 pandas 的时间序列图上绘制垂直线? [英] How do you plot a vertical line on a time series plot in Pandas?
本文介绍了您如何在 pandas 的时间序列图上绘制垂直线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Pandas系列图中绘制垂直线(vlines)?我正在使用Pandas绘制滚动装置等,并想用垂直线标记重要位置.是否可以使用vlines或类似的方法来完成此任务?如果是这样,有人可以提供一个例子吗?在这种情况下,x轴是日期时间.
How do you plot a vertical line (vlines) in a Pandas series plot? I am using Pandas to plot rolling means, etc and would like to mark important positions with a vertical line. Is it possible to use vlines or something similar to accomplish this? If so, could someone please provide an example? In this case, the x axis is date-time.
推荐答案
plt.axvline(x_position)
它采用标准绘图格式设置选项(linestlye
,color
等)
It takes the standard plot formatting options (linestlye
, color
, ect)
如果您引用了axes
对象:
ax.axvline(x, color='k', linestyle='--')
这篇关于您如何在 pandas 的时间序列图上绘制垂直线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文