|
From: Daniel J S. <dan...@ie...> - 2016-11-28 04:45:07
|
On 11/21/2016 12:12 PM, Ethan A Merritt wrote: > On Friday, 18 November, 2016 22:06:54 Daniel J Sebald wrote: >> I just used the time format in a plot. It's nice, incorporating the >> date and time and all. So thank you to whomever. >> >> It did take me a bit to figure out though why something like this failed: >> >> set timefmt "%m/%d/%y %H:%M" >> plot "data" using 1:2 >> >> with data something like >> >> 03/03/16 11:30 23.5 >> 03/03/16 11:45 24.8 >> ... >> >> It's because the datafile.c reading routine recognizes that first space >> as a delimiter such that field ':2' is actually 11 in both cases shown. >> That's fine, as the following works: >> >> plot "data" using 1:3 >> >> and the documentation gives proper examples and all, if not explicitly >> stating. >> >> However, it's a bit of a mental juxtaposition because the person >> scripting the code is thinking of the "03/03/16 11:30" as the "first" >> entry. Now, gnuplot has string inputs, such as in energy_circles.dat of >> the demo subdirectory. So, I'm wondering if the the date/time data >> entry could also accept a datafile string. It shouldn't be too much of >> a C-code alteration. For example, this might be the equivalent to the >> above: >> >> plot "data" using 1:2 >> >> with data >> >> "03/03/16 11:30" 23.5 >> "03/03/16 11:45" 24.8 >> ... >> >> I tried that, and gnuplot doesn't allow it > > Gnuplot does allow it. > Your test commands and data are plotted correctly so long as you > tell gnuplot that it is wrapped in a string: > > plot "data" using (strcol(1)):2 > > where strcol(N) is shorthand for stringcolumn(N) > > Ethan I did try this the other day when I was busy working on some code. It does work, thanks. I think this would be a good example to include as well, simply because it seems a more natural way to think of things for computer users, i.e., the two columns and also that a date/time field would be thought of as a string. Dan |