我使用以下代码显示库存数据:
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()
在某些日期位置,我想添加直接指向图表的箭头。 我怎么能这样做?
答案 0 :(得分:1)
尝试,
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)是您想要注释的文本的位置