本文介绍了gnuplot中的垂直堆叠多图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在gnuplot中以垂直堆叠的方式绘制5个图.有许多水平(共享x轴)图.我试图调整他们的解决方案.但不知何故.这是代码.

I am trying to plot 5 graph in vertically stacked pattern in gnuplot. There are many horizontally (x axis shared) graphs. I tried to adapt their solution. But somehow not works. Here is code.

set key bottom center
 NX=5; NY=1
 DX=0.01; DY=0.01; SX=0.25; SY=0.85
 set bmargin DX; set tmargin DX; set lmargin DY; set rmargin DY
 set size SX*NX+DX*4,SY*NY+DY*4
 set multiplot layout 1,5 #title 'Distance from inlet boundary' font #'areal,18'

 #1set title 'sa4(210)'
 set size SX,SY
 set label 1 '50m' at 1.5, 1.5 #font 'areal,15'
 set x2tics (0, 0.01, 0.02)
 set xtics (0, 2, 4)
 set ytics (-15, -10, -5, 0)
 set x2range [-0.001:0.02]
 set xrange [0:4]
 set yrange [-15:0]
 set ylabel 'metre(s) below sea level'
 set key bottom
 set xtics nomirror #smooth bezier w p csplines
 set origin DX,DY;
 plot 'so10.dat' u 2:1 w p pt 7 lc rgb 'red' title 'Salinity' axes x2y1,\
      'so10.dat' u 3:1 w p pt 8 lc rgb 'blue' title 'Sediment' axes x1y1

 #2set title 'sa4(210)'
 set size SX,SY
 set label 1 '250m' at 1.5, 1.5 #font 'areal,15'
 set x2tics (0, 0.01, 0.02)
 set xtics (0, 2, 4)
 set x2tics
 set x2range [-0.001:0.02]
 set xrange [0:4]
 unset ylabel
 unset ytics
 set key bottom
 set xtics nomirror #smooth bezier w p csplines
 set origin DX+SX,DY;
 plot 'so50.dat' u 2:1 w p pt 7 lc rgb 'red' title 'Salinity' axes x2y1,\
      'so50.dat' u 3:1 w p pt 8 lc rgb 'blue' title 'Sediment' axes x1y1

 #3set title 'sa4(210)'
 set size SX,SY
 set label 1 '750m' at 4.0, 1.5 #font ',15'
 set x2tics (0, 0.01, 0.02)
 set xtics (0, 5, 10)
 set x2tics
 set x2range [-0.001:0.02]
 set xrange [0:10]
 unset ylabel
 set key bottom
 set xtics nomirror #smooth bezier w p csplines
 set origin DX+SX*2,DY;
 plot 'so150.dat' u 2:1 w p pt 7 lc rgb 'red' title 'Salinity' axes x2y1,\
      'so150.dat' u 3:1 w p pt 8 lc rgb 'blue' title 'Sediment' axes x1y1

 #4set title 'sa4(210)'
 set size SX,SY
 set label 1 '850m' at 4.0, 1.5 #font ',15'
 set x2tics (0, 0.01, 0.02)
 set xtics (0, 6, 12)
 set x2tics
 set x2range [-0.001:0.02]
 set xrange [0:12]
 unset ylabel
 set key bottom
 set xtics nomirror #smooth bezier w p csplines
 set origin DX+SX*3,DY;
 plot 'so170.dat' u 2:1 w p pt 7 lc rgb 'red' title 'Salinity' axes x2y1,\
      'so170.dat' u 3:1 w p pt 8 lc rgb 'blue' title 'Sediment' axes x1y1

 #5set title 'sa4(210)'
 set size SX,SY
 set label 1 '950m' at 4.0, 1.5 #font ',15'
 set x2tics (0, 0.01, 0.02)
 set xtics (0, 5, 10)
 set x2tics
 set x2range [-0.001:0.02]
 set xrange [0:10]
 unset ylabel
 set key bottom
 set xtics nomirror #smooth bezier w p csplines
 set origin DX+SX*4,DY;
 plot 'so190.dat' u 2:1 w p pt 7 lc rgb 'red' title 'Salinity' axes x2y1,\
      'so190.dat' u 3:1 w p pt 8 lc rgb 'blue' title 'Sediment' axes x1y1

 unset multiplot

其中四个给出下面的图.代码必须生成5个图形.生成的图像

Which gives below 4 graph in one. Code must generate 5 graph.Generated image

原始图片如下.我想删除图表之间的空白.原始图片

Original image is below. I want to remove blank space between graphs.Original image

推荐答案

Gnuplot空间不足.您需要修复set sizeset origin命令,以免在绘制区域之外进行绘制.现在,您的SX=0.25表示每个子图的水平尺寸占用了可用空间的25%,因此只有4个子图可以使用此设置.然后需要将第五个子图放置在绘图区域之外.

Gnuplot is running out of space. You need to fix your set size and set origin commands so that you don't plot outside of the plotting area. Right now, your SX=0.25 means that the horizontal dimension of each subplot takes 25% of the available space, thus only 4 subplots can fit with this setting. The fifth subplot is then required to be placed beyond the plotting area.

还请注意,通过设置原点和尺寸,您将覆盖定义的multiplot layout.

Note also that by setting the origin and the size you're overriding your defined multiplot layout.

通常,在进行这种打印样式时,定义边距而不是大小和原点可能是一个更好的主意.

Usually, when doing this kind of plotting style, it might be a better idea to define the margins rather than the size and origin.

这篇关于gnuplot中的垂直堆叠多图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 03:02