4

I'm getting an error:

Skipping data file with no valid points

when trying to generate a graph from a csv file using gnuplot, any help is much appreciated!

sample.csv

timestamp,unit,maximum,average
Thu Jan 29 10:57:00 GMT 2015,Percent,22.96,7.723999999999999
Thu Jan 29 10:52:00 GMT 2015,Percent,62.79,26.227999999999998
Thu Jan 29 10:47:00 GMT 2015,Percent,46.54,15.075999999999999

run_gnuplot.sh

#!/bin/bash
gnuplot << eor
set terminal png 
set output 'output.png'
set style data linespoints
set datafile separator ","
set xlabel "timestamp"
set ylabel "percent"
plot "sample.csv" using 1:3 title "Maximum" using 1:4 title "Average"  
eor

Error:

bash-4.1$ ./run_gnuplot.sh 
Could not find/open font when opening font "arial", using internal non-scalable font

gnuplot> plot "sample.csv" using 1:3 title "Maximum" using 1:4 title "Average"  
                                           ^
         line 0: warning: Skipping data file with no valid points

gnuplot> plot "sample.csv" using 1:3 title "Maximum" using 1:4 title "Average"  
                                                     ^
         line 0: x range is invalid

1 Answer 1

4

You must tell gnuplot, that the first column is to be treated as time data with

set xdata time

You also must give the time format for parsing the first column. Unfortunately, gnuplot doesn't support reading in the day of the week.

Either change the format of the data written to the file, or filter the day of the week with an external tool like cut:

set xdata time
set timefmt '%b %d %H:%M:%S GMT %Y'
set datafile separator ','

plot '< tail -n +2 sample.csv | cut -f 1 --complement -d" "' using 1:3, '' using 1:4

The tail part to skip the first line isn't necessary with version 5.0.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks @Christoph, this almost works - though on the graph its only showing the minute part of the timestamp on the x axis? For example, 47:00, 48:00, 49:00, ...
You must set an output format as you wish: set format x '%H:%M:%S' to show hours, minutes and seconds.
could someone explain what the cut -f 1 --complement -d" " part does? i can't figure it out..
@ak1ra That removes the data until the first whitespace in every row.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.