Gnuplot组按年/月分组

时间:2017-08-17 18:25:24

标签: gnuplot

我第一次使用gnuplot并且我的数据文件data.csv具有以下内容

2017-05-28,50000
2017-07-13,100
2017-07-14,3217
2017-01-23,2052
2017-01-24,1954
2017-01-25,1664

现在我尝试使用以下设置进行绘图

set title 'My First Graph'
set ylabel 'Total per day'
set xlabel 'Date'
set grid
set term png
set datafile separator ","
set output 'graph.png'
set timefmt '%Y-%m-%d'
set format x "%Y-%m"
plot 'data.csv'

首先我得到了line 10: Bad format character,我不明白

1 个答案:

答案 0 :(得分:1)

您需要添加set xdata timeplot,并明确指定两列:

set title 'My First Graph'
set ylabel 'Total per day'
set xlabel 'Date'
set grid
set datafile separator ","
set timefmt '%Y-%m-%d'
set format x "%Y-%m"
set xdata time
plot 'data.csv' using 1:2

给出

enter image description here