时序图是常见的一种数据绘图,最典型的时序数据是天气数据,天气温度、湿度等都是随着时间变化的,本文给出一个例子是以lamost气
时序图是常见的一种数据绘图,最典型的时序数据是天气数据,天气温度、湿度等都是随着时间变化的,本文给出一个例子是以lamost气象站采集的一段时间数据,使用gnuplot绘出实时温湿度变化曲线。
天气数据:
time mjd temp rhum pres wind_avg wind_max wind_dir dewpoint2008-12-14 18:02:00 78933242 -2.4 33 915.5 2.6 4.2 76 -16.462008-12-14 18:04:00 78933244 -2.3 33 915.6 2.8 4.6 75 -16.382008-12-14 18:06:00 78933246 -2.4 33 915.6 2.7 4.6 80 -16.462008-12-14 18:08:00 78933248 -2.4 33 915.6 2.7 5.2 75 -16.462008-12-14 18:10:00 78933250 -2.4 33 915.5 3.8 7.1 78 -16.462008-12-14 18:12:00 78933252 -2.3 33 915.6 3.3 6.4 76 -16.382008-12-14 18:14:00 78933254 -2.3 33 915.6 2.8 5.9 74 -16.382008-12-14 18:16:00 78933256 -2.3 33 915.5 3.5 8 74 -16.382008-12-14 18:18:00 78933258 -2.3 33 915.6 3.1 7.4 79 -16.382008-12-14 18:20:00 78933260 -2.3 33 915.7 2.8 5.9 74 -16.382008-12-14 18:22:00 78933262 -2.3 34 915.7 1.7 4 80 -16.022008-12-14 18:24:00 78933264 -2.4 34 915.7 2.6 4.1 76 -16.112008-12-14 18:26:00 78933266 -2.4 34 915.8 2.5 4 74 -16.112008-12-14 18:28:00 78933268 -2.3 33 915.8 2.7 3.7 75 -16.382008-12-14 18:30:00 78933270 -2.2 33 915.8 4.2 6.3 75 -16.292008-12-14 18:32:00 78933272 -2.1 33 915.9 2.9 5.6 77 -16.22008-12-14 18:34:00 78933274 -2.2 34 915.9 3.3 5.3 73 -15.932008-12-14 18:36:00 78933276 -2.2 34 915.9 3.3 4.9 75 -15.932008-12-14 18:38:00 78933278 -2.2 34 915.9 2.7 4.3 71 -15.932008-12-14 18:40:00 78933280 -2.2 34 915.9 4 5.6 73 -15.932008-12-14 18:42:00 78933282 -2.1 33 915.9 3.8 5.1 73 -16.22008-12-14 18:44:00 78933284 -2.1 33 915.9 3.6 5.4 73 -16.2...............曲线图中需要有中文的内容,因此必须先指定中文字体,下面例子是方正黑体,字号11,绘出的图是png格式,,文件名w.png,图像大小1000x1000。
时序数据必须指定时间的格式,下面例子的格式是:
set timefmt %y-%m-%d %h:%m:%s更多的时间格式为:
格式说明
%d日期:1-31
%m月份:1-12
%y年:0-99
%y年,四位数
%j一年中的天数:1-365
%h小时:0-23
%m分钟:0-59
%sunix时间
%s秒:0-59
%b三个字母的月份缩写
%b月份名称
程序如下:
set terminal png font './font/fzht.ttf,11' size 1000,1000 set output w.pngset multiplot layout 2, 1 title lamost 天气信息#set size ratio 0.4set title lamost 天气信息 - 温度 露点温度 相对湿度图 font './font/fzht.ttf,13'set xdata timeset xlabel \n时间set ylabel 温度 / 露点温度 (c)set timefmt %y-%m-%d %h:%m:%sset grid#set yrange [-3:6]set y2label 相对湿度 (%)set y2ticsplot 'w.dat' using 1:4 with line title 温度, \ 'w.dat' using 1:10 with line title 露点温度, \ 'w.dat' using 1:5 axes x1y2 with line title 相对湿度#set title lamost 天气信息 - 风速 大气压图 font './font/fzht.ttf,13'set xdata timeset xlabel \n时间set ylabel 风速 (m/s)set timefmt %y-%m-%d %h:%m:%sset grid#set nokeyset y2label 大气压 (hpa)set y2ticsplot 'w.dat' using 1:8 with line title 瞬时最大风速, \ 'w.dat' using 1:7 with line title 平均风速, \ 'w.dat' using 1:6 axes x1y2 with line title 大气压程序名称demo.gp,运行程序:
gnuplot demo.gp效果图
本文永久更新链接地址: