I am using Gnuplot_i library (version 2.11) in C -code which generates some png -pictures. However time/date column does not format correctly.
Source:
gnuplot_ctrl * h0 ;
h0 = gnuplot_init() ;
gnuplot_set_xlabel(h0, "Header") ;
gnuplot_cmd(h0, "set terminal png size 800,480") ;
gnuplot_cmd(h0, "set output 'picture.png'") ;
gnuplot_cmd(h0, "set xdata time") ;
gnuplot_cmd(h0, "set timefmt '%Y-%m-%d-%H:%M'") ;
gnuplot_cmd(h0, "set format x '%H:%M' ") ;
gnuplot_cmd(h0, "set grid") ;
gnuplot_cmd(h0, "plot \"datafile.tsv\" u 1:2 w l t \"Title\" ");
gnuplot_close(h0) ;
datafile.tsv contains:
2017-09-08-18:03 12.69
2017-09-08-18:04 12.69
2017-09-08-18:05 12.69
2017-09-08-18:06 12.69
...
Unfortunately command gnuplot_cmd(h0, "show timefmt");
produces error:
Warning: empty x range
[1.48323e+09:1.48323e+09],
adjusting to [1.4684e+09:1.49806e+09] Default format for reading time data is "%Y-No such file or directory-0- %H:%M"
Why %m get formatted "No such file or directory" and %d like "0" ?
I've read Gnuplot_i manual, and the command gnuplot_cmd
has the parameter cmd
that should be formatted like in the printf
function. Your time format is interpreted as a format string because of the '%' characters. You should use instead something like
gnuplot_cmd(h0, "set timefmt \"%%Y-%%m-%%d-%%H:%%M\"");
gnuplot_cmd(h0, "set format x \"%%H:%%M\"") ;