gnuplot 绘制时间序列图

假设我们有数据文件“timedat.dat文件的内容如下。

    #日/月/年 值  
    01/06/93    100  
    17/08/93    900  
    04/10/93    1300  
    11/10/93    300  
    28/10/93    1000  

可以看到,横坐标是时间值,需要将这个信息告诉 gnuplot 。利用如下的命令。
set xdata time  
类似的命令还包括:
    set ydata time  
    set zdata time  
    set x2data time  
    set y2data time  
    set cbdata time  

如果要回到原来的那种横坐标为数值的状态,可以执行如下命令:

set xdata

下面还需要告诉  gnuplot  数据文件中的时间格式是什么样,要利用如下的命令

set timefmt "<format string>"  

其中format string 用来描述数据文件中时间的格式。对于我们的数据文件,可以这样设置:

set timefmt "%d/%m/%y"  


Gnuplot 支持的格式如下:

格式

解释

%d

day of the month, 131

%m

month of the year, 112 

%y

year, 099

%Y

year, 4-digit

%j

day of the year, 1365

%H

hour, 024

%M

minute, 060

%s 

seconds since the Unix epoch (1970-01-01 00:00 UTC)

%S

second, integer 060 on output, (double) on input

%b

three-character abbreviation of the name of the month

%B

name of the month

 到这里就设置好了,下面开始显示

plot 'timedat.dat' using 1:2 with points ps 3 pt 6 title ""  

输出的图形如下。  

可以看到输出的横坐标只有月份和日期,没有年份信息。如果需要加入年份信息,可以这样设置:

    set format x "%y/%m/%d"  

然后更新一下输出:
Replot  


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值