python - Plot numpy rec array with date -
i read pickled numpy array structure:
>>> h.shape (256,) >>> h[:10] rec.array([(datetime.date(2011, 1, 2), 1, -3, 1014), (datetime.date(2011, 1, 3), 3, -6, 1016), (datetime.date(2011, 1, 4), 0, -9, 1023), (datetime.date(2011, 1, 5), 1, -6, 1023), (datetime.date(2011, 1, 6), 3, -2, 1026), (datetime.date(2011, 1, 7), 2, -1, 1029), (datetime.date(2011, 1, 8), -1, -1, 1027), (datetime.date(2011, 1, 9), -1, -2, 1025), (datetime.date(2011, 1, 10), -1, -2, 1025), (datetime.date(2011, 1, 11), 3, 3, 1020)], dtype=[('date', '|o4'), ('high', '|i1'), ('low', '|i1'), ('pres', '<i2')])
and can't find how plot matplotlib. tried use plt.plot_date(...)
on combination error. can point me right direction how plot simple line graph x-axis date , y-axis other value array, let's pres
labeled data?
given h
numpy.recarray
can achieve basic plotting using
plt.plot_date(h.date, h.pres, linestyle='-', marker=none) plt.gcf().autofmt_xdate() # optional; included format x-axis dates
further customization might needed plot way want it.
Comments
Post a Comment