Gnuplot多个图并列显示时如何设置y轴刻度?

3

我正在使用Perl脚本解析一些天气数据,然后利用gnuplot在3行2列的显示中绘制这些数据。除了最后一个图表“累积降雨量”之外,我的所有图表似乎都正常工作。实际上,该图表绘制得正确,但是y轴的比例似乎使用了“分钟降雨量”图表的设置。有人可以查看我的gnuplot代码并看到我可能出了什么问题吗?谢谢任何帮助。

set terminal wxt size 1500,750
set size ratio 0.25
set multiplot layout 3,2 title "Weather Data at Fort Worth Alliance Airport For 10/26/2013"
set title "Temperature/Dewpoint"
unset key
set xdata time
set timefmt "%H:%M"
set xrange ["00:00" : "24:00"]
set xtics "00:00" , "02:00" , "24:00"
set xlabel "Time of Day"
set ylabel "Temperature/Dewpoint (° F)"
set autoscale y
set grid
set format x "%H:%M"
set format y "%5.1f"
set style data lines
plot "output2.dat" using 1:3 title 'Temperature',\
"output2.dat" using 1:4 title 'Dewpoint'

set title "Barometric Pressure"
unset key
set xdata time
set timefmt "%H:%M"
set xrange ["00:00" : "24:00"]
set xtics "00:00" , "02:00" , "24:00"
set xlabel "Time of Day"
set ylabel "Pressure (in Hg)"
set autoscale y
set grid
set format x "%H:%M"
set format y "%5.2f"
set style data lines
plot "output2.dat" using 1:2 title 'Pressure' lt -1

set title "Peak Wind Speed"
unset key
set xdata time
set timefmt "%H:%M"
set xrange ["00:00" : "24:00"]
set xtics "00:00" , "02:00" , "24:00"
set xlabel "Time of Day"
set ylabel "Wind Speed (kt)"
set autoscale y
set yrange [0:*]
set grid
set format x "%H:%M"
set format y "%5.0f"
set style data lines
plot "output1.dat" using 1:3 title 'Peak Wind Speed' lt 3

set title "Surface Visibility"
unset key
set xdata time
set timefmt "%H:%M"
set xrange ["00:00" : "24:00"]
set xtics "00:00" , "02:00" , "24:00"
set xlabel "Time of Day"
set ylabel "Visibility (SM)"
set yrange [0:10]
set ytics "0" , "1" , "10"
set grid
set format x "%H:%M"
set format y "%4.0f"
set style data lines
plot "output1.dat" using 1:2 title 'Surface Visibility' lt rgb "goldenrod"

set title "One Minute Rainfall"
unset key
set xdata time
set timefmt "%H:%M"
set xrange ["00:00" : "24:00"]
set xtics "00:00" , "02:00" , "24:00"
set xlabel "Time of Day"
set ylabel "Rainfall (in)"
set autoscale y
set yrange [0:0.25]
set ytics "0" , "0.05" , "0.25"
set grid
set format x "%H:%M"
set format y "%4.2f"
set style data lines
plot "output2.dat" using 1:5 title 'One Minute Rainfall' lt rgb "green"

set title "Accumulated Rainfall"
unset key
set xdata time
set timefmt "%H:%M"
set xrange ["00:00" : "24:00"]
set xtics "00:00" , "02:00" , "24:00"
set xlabel "Time of Day"
set ylabel "Rainfall (in)"
set autoscale y
set yrange [0:*]
set grid
set format x "%H:%M"
set format y "%5.2f"
set style data lines
plot "output2.dat" using 1:6 title 'Accumulated Daily Rainfall' lt rgb "green"
unset multiplot

Output1.dat 示例

 19:00   0.82   28
 19:01   0.48   28
 19:02   0.41   30
 19:03   0.41   29
 19:04   0.29   32
 19:05   0.24   31
 19:06   0.27   25
 19:07   0.32   21
 19:08   0.47   17
 19:09   0.56   15
 19:10   0.73   13

Output2.dat样例

  19:00   29.327    60   59   0.07   0.47
  19:01   29.331    60   59   0.10   0.57
  19:02   29.338    59   58   0.09   0.66
  19:03   29.345    59   58   0.10   0.76
  19:04   29.348    59   58   0.11   0.87
  19:05   29.350    57   57   0.12   0.99
  19:06   29.350    57   57   0.11   1.10
  19:07   29.349    57   56   0.09   1.19
  19:08   29.350    57   57   0.07   1.26
  19:09   29.355    57   56   0.08   1.34
  19:10   29.362    57   56   0.05   1.39
1个回答

1
上一个图的比例是好的,但使用了前一个图的 ytic 设置。在最后一个图中只需使用“set ytics auto”,就可以了。
顺便说一句:要在最后一个 x 刻度上显示“24:00”,请使用“set xtics add(“24:00”“24:00”)”。
你的许多设置都是冗余的,请参见下面简化的脚本:
set terminal wxt size 1500,750
set size ratio 0.25

unset key
set xdata time
set timefmt "%H:%M"
set xrange ["00:00" : "24:00"]
set xtics add ("24:00" "24:00")
set format x "%H:%M"
set xlabel "Time of Day"
set style data lines
set grid

set multiplot layout 3,2 title "Weather Data at Fort Worth Alliance Airport For 10/26/2013"

set title "Temperature/Dewpoint"
set ylabel "Temperature/Dewpoint (° F)"
set format y "%5.1f"
plot "output2.dat" using 1:3 title 'Temperature',\
     "" using 1:4 title 'Dewpoint'

set title "Barometric Pressure"
set ylabel "Pressure (in Hg)"
set format y "%5.2f"
plot "output2.dat" using 1:2 title 'Pressure' lt -1

set title "Peak Wind Speed"
set ylabel "Wind Speed (kt)"
set yrange [0:*]
set format y "%5.0f"
plot "output1.dat" using 1:3 title 'Peak Wind Speed' lt 3

set title "Surface Visibility"
set ylabel "Visibility (SM)"
set yrange [0:10]
set ytics 1
set format y "%4.0f"
plot "output1.dat" using 1:2 title 'Surface Visibility' lt rgb "goldenrod"

set title "One Minute Rainfall"
set ylabel "Rainfall (in)"
set yrange [0:0.25]
set ytics 0.05
set format y "%4.2f"
plot "output2.dat" using 1:5 title 'One Minute Rainfall' lt rgb "green"

set title "Accumulated Rainfall"
set ylabel "Rainfall (in)"
set yrange [0:*]
set ytics auto
set format y "%5.2f"
plot "output2.dat" using 1:6 title 'Accumulated Daily Rainfall' lt rgb "green"
unset multiplot

非常感谢您的帮助!那个完美地解决了我的问题。我也很感激您帮我简化脚本!每天都在学习一点点。再次感谢! - wxman

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接