I am trying to plot a graph by datetime value.
Consider this example CSV (streetnoise.csv
):
datetime,noise level
2018-12-03 03:31:12.592,10
2018-12-03 03:31:15.832,10
2018-12-03 03:31:17.062,11
2018-12-03 03:31:19.292,12
2018-12-03 03:31:23.532,11
2018-12-03 03:31:25.762,10
2018-12-03 03:31:26.002,23
2018-12-03 03:31:28.242,10
2018-12-03 03:31:34.492,10
2018-12-03 03:31:34.722,9
So this just stores street noise measurements as tuples. I want to draw a plot from that, using Octave:
# Load the data
pkg load io
csv_data = csv2cell("streetnoise.csv")
# Parse the datetimes
datevalues = datenum(csv_data(2:end,1), "yyyy-mm-dd HH:MM:SS.FFF")
seconds = (datevalues - datevalues(1)) * 24 * 60 * 60
# Get noise levels
noiseLevels = [csv_data{2:end,2}]
# Plot by seconds since start
h = figure(1)
plot(seconds, noiseLevels)
title("Levels per seconds")
xlim([min(seconds) max(seconds)])
# Plot by datenum
i = figure(2)
plot(datevalues, noiseLevels)
title("Levels per datevalues")
The content of the first figure is readable:
However, it is not really understandable, since the reader has to know when measurements started an to calculate the time.
The second figure is just empty:
How can I plot with the datenum values? I wanted to try datenum parsing for labelling afterwards, but I didn't even come that far.
When I add xlim([min(datevalues) max(datevalues)])
, I only get to see the y axis.