時(shí)序圖是常見的一種數(shù)據(jù)繪圖,最典型的時(shí)序數(shù)據(jù)是天氣數(shù)據(jù),天氣溫度、濕度等都是隨著時(shí)間變化的,本文給出一個(gè)例子是以LAMOST氣
時(shí)序圖是常見的一種數(shù)據(jù)繪圖,最典型的時(shí)序數(shù)據(jù)是天氣數(shù)據(jù),天氣溫度、濕度等都是隨著時(shí)間變化的,本文給出一個(gè)例子是以LAMOST氣象站采集的一段時(shí)間數(shù)據(jù),使用gnuplot繪出實(shí)時(shí)溫濕度變化曲線。
天氣數(shù)據(jù):
time mjd temp rhum pres wind_avg wind_max wind_dir dewpoint 2008-12-14 18:02:00 78933242 -2.4 33 915.5 2.6 4.2 76 -16.46 2008-12-14 18:04:00 78933244 -2.3 33 915.6 2.8 4.6 75 -16.38 2008-12-14 18:06:00 78933246 -2.4 33 915.6 2.7 4.6 80 -16.46 2008-12-14 18:08:00 78933248 -2.4 33 915.6 2.7 5.2 75 -16.46 2008-12-14 18:10:00 78933250 -2.4 33 915.5 3.8 7.1 78 -16.46 2008-12-14 18:12:00 78933252 -2.3 33 915.6 3.3 6.4 76 -16.38 2008-12-14 18:14:00 78933254 -2.3 33 915.6 2.8 5.9 74 -16.38 2008-12-14 18:16:00 78933256 -2.3 33 915.5 3.5 8 74 -16.38 2008-12-14 18:18:00 78933258 -2.3 33 915.6 3.1 7.4 79 -16.38 2008-12-14 18:20:00 78933260 -2.3 33 915.7 2.8 5.9 74 -16.38 2008-12-14 18:22:00 78933262 -2.3 34 915.7 1.7 4 80 -16.02 2008-12-14 18:24:00 78933264 -2.4 34 915.7 2.6 4.1 76 -16.11 2008-12-14 18:26:00 78933266 -2.4 34 915.8 2.5 4 74 -16.11 2008-12-14 18:28:00 78933268 -2.3 33 915.8 2.7 3.7 75 -16.38 2008-12-14 18:30:00 78933270 -2.2 33 915.8 4.2 6.3 75 -16.29 2008-12-14 18:32:00 78933272 -2.1 33 915.9 2.9 5.6 77 -16.2 2008-12-14 18:34:00 78933274 -2.2 34 915.9 3.3 5.3 73 -15.93 2008-12-14 18:36:00 78933276 -2.2 34 915.9 3.3 4.9 75 -15.93 2008-12-14 18:38:00 78933278 -2.2 34 915.9 2.7 4.3 71 -15.93 2008-12-14 18:40:00 78933280 -2.2 34 915.9 4 5.6 73 -15.93 2008-12-14 18:42:00 78933282 -2.1 33 915.9 3.8 5.1 73 -16.2 2008-12-14 18:44:00 78933284 -2.1 33 915.9 3.6 5.4 73 -16.2 ...............曲線圖中需要有中文的內(nèi)容,因此必須先指定中文字體,下面例子是方正黑體,字號(hào)11,繪出的圖是png格式,,文件名w.png,圖像大小1000x1000。
時(shí)序數(shù)據(jù)必須指定時(shí)間的格式,下面例子的格式是:
set timefmt "%Y-%m-%d %H:%M:%S"更多的時(shí)間格式為:
格式說明
%d 日期:1-31
%m 月份:1-12
%y 年:0-99
%Y 年,四位數(shù)
%j 一年中的天數(shù):1-365
%H 小時(shí):0-23
%M 分鐘:0-59
%s UNIX時(shí)間
%S 秒:0-59
%b 三個(gè)字母的月份縮寫
%B 月份名稱
程序如下:
set terminal png font './font/fzht.ttf,11' size 1000,1000 set output "w.png" set multiplot layout 2, 1 title "LAMOST 天氣信息" # set size ratio 0.4 set title "LAMOST 天氣信息 - 溫度 露點(diǎn)溫度 相對(duì)濕度圖" font './font/fzht.ttf,13' set xdata time set xlabel "\n時(shí)間" set ylabel "溫度 / 露點(diǎn)溫度 (C)" set timefmt "%Y-%m-%d %H:%M:%S" set grid #set yrange [-3:6] set y2label "相對(duì)濕度 (%)" set y2tics plot 'w.dat' using 1:4 with line title "溫度", \ 'w.dat' using 1:10 with line title "露點(diǎn)溫度", \ 'w.dat' using 1:5 axes x1y2 with line title "相對(duì)濕度" # set title "LAMOST 天氣信息 - 風(fēng)速 大氣壓圖" font './font/fzht.ttf,13' set xdata time set xlabel "\n時(shí)間" set ylabel "風(fēng)速 (m/s)" set timefmt "%Y-%m-%d %H:%M:%S" set grid #set nokey set y2label "大氣壓 (hPa)" set y2tics plot 'w.dat' using 1:8 with line title "瞬時(shí)最大風(fēng)速", \ 'w.dat' using 1:7 with line title "平均風(fēng)速", \ 'w.dat' using 1:6 axes x1y2 with line title "大氣壓"程序名稱demo.gp,運(yùn)行程序:
gnuplot demo.gp效果圖
本文永久更新鏈接地址:
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com