|
From: Daniel J S. <dan...@ie...> - 2016-11-19 21:43:52
|
On 11/18/2016 10:06 PM, 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 (no surprise, as it isn't
> documented to do so). The way I see it, the user might be more inclined
> to think of date/time data in that fashion.
The documentation says:
In all cases, the numbers of each record of a data file must be separated
by white space (one or more blanks or tabs) unless a format specifier is
provided by the `using` option. This white space divides each record into
columns. However, whitespace inside a pair of double quotes is ignored
when
counting columns, so the following datafile line has three columns:
1.0 "second column" 3.0
Thinking more general, that begs the question as to why gnuplot couldn't
accept numbers within a string:
"1.0""second column""3.0"
or even CSV format:
1.0,second column,3.0
Not that I'm really keen on having that, but it may not be a far step
handling those formats.
Dan
|