Maison > base de données > tutoriel mysql > le corps du texte

时序图的绘制—使用Gnuplot

WBOY
Libérer: 2016-06-07 16:50:45
original
1681 Les gens l'ont consulté

时序图是常见的一种数据绘图,最典型的时序数据是天气数据,天气温度、湿度等都是随着时间变化的,本文给出一个例子是以LAMOST气

时序图是常见的一种数据绘图,最典型的时序数据是天气数据,天气温度、湿度等都是随着时间变化的,本文给出一个例子是以LAMOST气象站采集的一段时间数据,使用gnuplot绘出实时温湿度变化曲线。

天气数据:

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 ...............

曲线图中需要有中文的内容,因此必须先指定中文字体,下面例子是方正黑体,字号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

%s UNIX时间

%S 秒:0-59

%b 三个字母的月份缩写

%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 天气信息 - 温度 露点温度 相对湿度图" font './font/fzht.ttf,13' set xdata time set xlabel "\n时间" set ylabel "温度 / 露点温度 (C)" set timefmt "%Y-%m-%d %H:%M:%S" set grid #set yrange [-3:6] set y2label "相对湿度 (%)" set y2tics plot '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 time set xlabel "\n时间" set ylabel "风速 (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 "瞬时最大风速", \ 'w.dat' using 1:7 with line title "平均风速", \ 'w.dat' using 1:6 axes x1y2 with line title "大气压"

程序名称demo.gp,运行程序:

gnuplot demo.gp

效果图

本文永久更新链接地址:

linux

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!