8
给出一个DataFrame
,如:诠释点Matplotlib情节
LIST_PRICE SOLD_PRICE
MOYRLD
1999-03-31 317062.500000 314800
1999-06-30 320900.000000 307100
1999-09-30 400616.666667 366160
1999-12-31 359900.000000 NaN
2000-03-31 359785.714286 330750
使用代码:
import matplotlib.dates as mdates
ax3=df5.plot()
ax3.set_ylim(100000,600000)
ax3.set_title('Heatherwood-Quarterly')
我产生这样一个情节:
我无法弄清楚如何让轴附加一个nnotation? 这个例子Annotate Time Series plot in Matplotlib非常接近,但我不知道如何从DataFrame
指定x轴和y轴?
所以应该接近:
ax3.annotate('Test', (mdates.date2num(x[1]), y[1]), xytext=(15, 15),
textcoords='offset points', arrowprops=dict(arrowstyle='-|>'))
fig.autofmt_xdate()
plt.show()
但我应该使用什么来代替x[1]
和y[1]
得到轴?我试图['MORLD'][1]
和['SOLD_PRICE'][1]
,并得到index out of range
......
厕所在最后一个环节:http://pandas.pydata.org/pandas -docs/dev/cookbook.html#plotting – Jeff
似乎没有在Dataframe索引中使用Dataframe? – dartdog
随着大熊猫0.11.0和matplotlib 1.2.1看来,如果你使用'ax.annotate( '测试',(df5.index正常运行[1],DF5 [ 'SOLD_PRICE'] [1]),.. 。。。至少如果你的'DataFrame'的索引是'DatetimeIndex'。 – hooy