Reputation: 57
I have searched quite some time to resolve the following problem with gnuplot, but I could not find any helpful info. I hope somebody can help me:
I have data showing what percentage a user achieved at a certain date, like:
DATE;USERID;PERCENTAGE
2012-03-14;1;92.14
2012-03-13;2;93.55
2012-04-14;1;97.14
2012-04-13;2;83.55
2012-05-14;1;94.14
2012-05-13;1;95.55
I want to plot achieved percentage per user let's say from april 2012 onwards (the plot works fine for all dates).
I cannot use
set xdata time
as the x axis should contain userId. Unfortunately, also the following failed:
set datafile separator ";"
set timefmt "%Y-%m-%d"
plot bla.csv using 2:(timecolumn(1) > 2012-05-01 ? $3 : 1/0)
leading to the warning "Bad time format in string" and no filtering at all.
I am stuck with this since hours and can't find anything...
Upvotes: 2
Views: 324
Reputation: 48390
When using timecolumn
in the using
statement the corresponding value is given in seconds. Therefore, the timestamp read from the data file is compared with 2012, which is the numeric value extracted from your expression.
Use strptime
to format the comparison date:
set datafile separator ";"
fmt = "%Y-%m-%d"
set timefmt fmt
plot 'bla.csv' using 2:(timecolumn(1) > strptime(fmt, "2012-05-01") ? $3 : 1/0)
Upvotes: 1