Reputation: 20340
I'm on linux, learning gnuplot. My data.tsv looks like this:
1480420804 2016-11-29 04:00:04 -0800 foo1 $123.00 bar1
1480507205 2016-11-30 04:00:05 -0800 foo2 $124.25 bar2
1480593604 2016-12-01 04:00:04 -0800 foo3 $122.75 bar3
I'm using column #1 (seconds since epoch) as X, and column 4 (price) as Y.
This is my gnuplot script:
#!/usr/bin/gnuplot
set terminal png notransparent interlace size 640,480
set output "output.png"
set datafile separator tab
set xdata time
set timefmt "%s"
set format x "%4Y-%02m-%02d"
plot "data.tsv" using 1:4 title "Blah"
When I try to run this, I get the following error:
"./test.gp", line 9: warning: Skipping data file with no valid points
plot "data.tsv" using 1:4 title "Blah"
^
"./test.gp", line 9: x range is invalid
But if I remove all the dollar signs from the start of column 4 in my data.tsv file, then everything works.
My question: Is there a way to get gnuplot to accept or skip over the "$" in the prices in column #4?
Upvotes: 2
Views: 5597
Reputation: 20340
I tried to do (more-or-less) what @kebs suggested, but it failed with the same "x range is invalid" error message when I was calling it like this within gnuplot:
plot "< sed s/\$//g data.tsv" using 1:4 title "Blah"
I'm not too familiar with sed
, so I tried instead to use tr
, and that worked like a charm.
Line 9 of my gnuplot script was this:
plot "data.tsv" using 1:4 title "Blah"
I changed it to say this:
plot "< cat data.tsv | tr --delete '$'" using 1:4 title "Blah"
Upvotes: 1
Reputation: 6707
(This is not an answer to your question but an answer to your problem so be welcome to accept another answer if somebody comes up with something better)
Just preprocess you data file before plotting and remove the $
:
sed s/\$//g data.tsv >data2.tsv
Upvotes: 1