你如何在 Pandas 的时间序列图上绘制一条垂直线? [英] How do you plot a vertical line on a time series plot in Pandas?

查看:50
本文介绍了你如何在 Pandas 的时间序列图上绘制一条垂直线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 如何在 Pandas 系列图中绘制垂直线 (vlines)?
  • 我正在使用 Pandas 绘制滚动方式等,并想用垂直线标记重要位置.
  • 是否可以使用 vlines 或类似的东西来实现这一点?
  • 在本例中,x 轴是 datetime.
  • 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?
  • In this case, the x axis is datetime.

推荐答案

plt.axvline(x_position)

它采用标准绘图格式选项(linestlyecolor 等)

It takes the standard plot formatting options (linestlye, color, ect)

(文档)

如果您有对 axes 对象的引用:

If you have a reference to your axes object:

ax.axvline(x, color='k', linestyle='--')

这篇关于你如何在 Pandas 的时间序列图上绘制一条垂直线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆