I'm sourcing date in second since the epoch as a floating point number ( from time.time() ) and I'm trying to plot it converting it like this (line[0]):
x,y = [],[]
csv_reader = csv.reader(open(csvFile))
for line in csv_reader:
x.append(float(line[1]))
y.append(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(float(line[0]))))
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x,y,'o-')
fig.autofmt_xdate()
plt.show()
but matplotlib keeps on erroring out like this :
ValueError: invalid literal for float(): 2013-07-08 15:04:50
Any idea on how to format it properly ?
Cheers


yvalues a strings, like'2013-07-08 15:04:50', and yourxvalues are floats. Do you wantyvalues which are dates? That is possible, but it is usually done the other way around.(with dates on thex-axis.)