Issue
I have time series in a Pandas dateframe
with a number of columns which I'd like to plot. Is there a way to set the x-axis to always use the index from a dateframe
?
When I use the .plot()
method from Pandas the x-axis is formatted correctly however I when I pass my dates and the column(s) I'd like to plot directly to matplotlib the graph doesn't plot correctly. Thanks in advance.
plt.plot(site2.index.values, site2['Cl'])
plt.show()
FYI: site2.index.values
produces this (I've cut out the middle part for brevity):
array([
'1987-07-25T12:30:00.000000000+0200',
'1987-07-25T16:30:00.000000000+0200',
'2010-08-13T02:00:00.000000000+0200',
'2010-08-31T02:00:00.000000000+0200',
'2010-09-15T02:00:00.000000000+0200'
],
dtype='datetime64[ns]')
Solution
It seems the issue was that I had .values
. Without it (i.e. site2.index
) the graph displays correctly.
Answered By - Jason
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.