gpt4 book ai didi

python - 添加箭头到股票图表

转载 作者:太空宇宙 更新时间:2023-11-03 18:47:33 25 4
gpt4 key购买 nike

我使用以下代码来显示股票数据:

from pandas.io.data import get_data_yahoo
import matplotlib.pyplot as plt
data = get_data_yahoo("ADS", start = '2012-01-01', end = '2012-12-31')[['Close','Volume']]
data.plot(subplots = True, figsize = (8, 8));
plt.title('Adidas-Aktie 2012')
plt.legend(loc = 'best')
plt.show()

在某些日期位置,我想添加直接指向图表的箭头。我怎样才能做到这一点?

最佳答案

尝试,

 from pandas.io.data import get_data_yahoo
import matplotlib.pyplot as plt
data = get_data_yahoo("ADS", start = '2012-01-01', end = '2012-12-31' [['Close','Volume']]
ax = data.plot(subplots = True, figsize = (8, 8));
plt.title('Adidas-Aktie 2012')
plt.legend(loc = 'best')
ax[0].annotate('your text',xy =(locx,locy), xytext=(locx,locy), arrowprops = dict(facecolor = 'black')) # assuming the you want to annotate the first plot
plt.show()

在上面的代码中,(locx,locy) 是您想要注释的文本位置

关于python - 添加箭头到股票图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19164137/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com