我有一张我的portflio股票在一段时间内的图表,它如下所示:
我有一个每5分钟的价格,所以x数据是时间戳,y数据只是数字
我还有一个带有操作时间的数据框,其中包含操作时间及其类型(购买或出售),如下所示:
我想为我的图形上的每个操作添加一个点或某种标记,但我不知道怎么做,我没有y值。时间戳x值不同于操作x值,所以我不能只从现有图中获取y值。
这是我理想的设想,但对于初学者,我只想了解如何在图表上添加我的点:
.
我正在使用plotly,但我不在乎解决方案是否需要matplotlib或其他任何东西
Tags:
这在使用annotations时是完全可行的。操作数据框不必有y值,因为您可以在操作x值处使用股票数据中相应的y值。要打印红色标记,可以打印操作并根据需要设置标记属性
然后,您可以循环操作_df,并根据输入日期及其对应的股票投资组合y值在散点图上放置注释。下面是一个包含一些虚构数据的示例,因此您可能需要针对数据帧调整此代码
相关问题 更多 >
编程相关推荐