I am reading the text file that has two columns in the next format:
20120101 5.6
20120102 5.3
20120103 5.4
...
Where the first column is YYYYMMDD
yearmonthday and the second is a magnitude.
Here's what I am doing so far:
file = open('junk.txt','r')
lines = file.readlines()
file.close()
Magnitude=[]
Year=[]
for line in lines:
p=line.split()
Year.append(str(p[0]))
Magnitude.append(float(p[5]))
year = np.array(Year, dtype='datetime64[Y]')
mag=np.array(Magnitude)
fig2 = plt.figure()
ax2 = fig2.add_subplot(1,1,1)
ax2.plot_date(year, Cmag, color='k',linestyle='-',linewidth=2.0)
ax2.set_xlabel('Number of Events')
ax2.set_ylabel('Cumulative Moment')
However the format of the x
axis (time) is not correct. I would like to display the time in the format: yyymm
in the x
axis.
Here's a link with my output (figure):
https://drive.google.com/a/ucsc.edu/file/d/0B3Y1nDlkfy2VNjlBS2FrT0ZRWW8/view?usp=sharing
You can see that time isn't recognized correctly.