我收到错误:
跳过没有有效积分的数据文件
尝试使用gnuplot从csv文件生成图表时,非常感谢任何帮助!
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
错误:
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
答案 0 :(得分:4)
您必须告诉gnuplot,第一列将被视为
的时间数据set xdata time
您还必须提供解析第一列的时间格式。不幸的是,gnuplot在一周中没有支持阅读。
更改写入文件的数据格式,或使用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
版本5.0不需要跳过第一行的tail
部分。