Graph 带有xtics月份和年份的折线图
我已经成功地使用Gnuplot构建了一个折线图 现在我试着把日期放在我的x轴上。以下是我的数据:Graph 带有xtics月份和年份的折线图,graph,gnuplot,Graph,Gnuplot,我已经成功地使用Gnuplot构建了一个折线图 现在我试着把日期放在我的x轴上。以下是我的数据: service1 service2 service3 12/28/2014 0 0 0 11/24/2014 1 2 0 10/06/2014 5 4 1 08/30/2014 10 6 0 03/13/2014 15 8 0 这是我添加日期格式之前的打印文件: set term pos eps font 20 set output
service1 service2 service3
12/28/2014 0 0 0
11/24/2014 1 2 0
10/06/2014 5 4 1
08/30/2014 10 6 0
03/13/2014 15 8 0
这是我添加日期格式之前的打印文件:
set term pos eps font 20
set output 'line.eps'
plot "data.dat" using 2 smooth cumulative t 's1' with lines, \
"data.dat" using 3 smooth cumulative t 's2' with lines, \
"data.dat" using 4 smooth cumulative t 's3' with lines
我将日期格式添加到绘图中,如下所示:
set term pos eps font 20
set output 'line.eps'
set xdata time
set timefmt "%m/%d/%y"
set xrange ["01/01/2009":"12/01/2014"]
plot "data.dat" using 2 smooth cumulative t 's1' with lines, \
"data.dat" using 3 smooth cumulative t 's2' with lines, \
"data.dat" using 4 smooth cumulative t 's3' with lines
plot "data.dat" using 1:2 smooth cumulative t 's1' with lines, \
"data.dat" using 1:3 smooth cumulative t 's2' with lines, \
"data.dat" using 1:4 smooth cumulative t 's3' with lines
错误是:
"plot.plt", line 10: Need full using spec for x time data
之后,我尝试添加并更改绘图脚本,如下所示:
set term pos eps font 20
set output 'line.eps'
set xdata time
set timefmt "%m/%d/%y"
set xrange ["01/01/2009":"12/01/2014"]
plot "data.dat" using 2 smooth cumulative t 's1' with lines, \
"data.dat" using 3 smooth cumulative t 's2' with lines, \
"data.dat" using 4 smooth cumulative t 's3' with lines
plot "data.dat" using 1:2 smooth cumulative t 's1' with lines, \
"data.dat" using 1:3 smooth cumulative t 's2' with lines, \
"data.dat" using 1:4 smooth cumulative t 's3' with lines
给了我一个错误:
service1 service2 service3
data.dat:1:"plot.plt", line 10: illegal month
似乎与前面的图表有所不同。有人能告诉我怎么解决这个问题吗?我的期望如下图所示,但在x轴上使用月份格式
感谢错误消息告诉您,在包含
service1 service2service3
的文件data.dat
的第一行中,gnuplot遇到了一个非法月份
你也可以
- 删除第一行
- 评论第一行
- 使用
every::1跳过第一行
%Y
指定。以下工作在这里很好:
set xdata time
set timefmt "%m/%d/%Y"
set format x "%m/%Y"
set xrange ["01/01/2009":"12/01/2014"]
plot "data.dat" using 1:2 every ::1 smooth cumulative t 's1' with lines, \
"data.dat" using 1:3 every ::1 smooth cumulative t 's2' with lines, \
"data.dat" using 1:4 every ::1 smooth cumulative t 's3' with lines
太好了!你好,克里斯托夫。这是我的工作。因为射程是6年。无法读取x轴。是否可以对范围进行分类?可能每3个月或6个月?您可以设置XTIC的频率。该值必须以秒为单位,因此您可以尝试使用
设置xtics 3*30*24*60*60
。我不确定gnuplot如何在内部处理每月不同的天数。