Gnuplot:多图大小和一个图的缩放 [英] Gnuplot: Multiplot size and scaling of one plot

查看:530
本文介绍了Gnuplot:多图大小和一个图的缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个多重绘图:

由以下代码生成:

set terminal pdf size 15,10
set output "graph.pdf"
set key off
set multiplot layout 5, 1 scale 1, 1
set style data histograms
set style histogram
set style fill solid border -1
set boxwidth 0.75
set yrange [0:178]
set ytics 50
set xtics offset 0,graph 0.01
set xtics font ",20"
set x2tics font ",20"
set ytics font ",20"
set tmargin 3
set bmargin 3
set style line 1 linetype -1 linewidth 3
set grid mxtics
set xtics (0.5 1,1.5 1,2.5 1,3.5 1,4.5 1,5.5 1,6.5 1,7.5 1,8.5 1,9.5 1,10.5 1,11.5 1,12.5 1,13.5 1,14.5 1,15.5 1,16.5 1,17.5 1,18.5 1,19.5 1,20.5 1,21.5 1,22.5 1,23.5 1,24.5 1,25.5 1,26.5 1,27.5 1,28.5 1,29.5 1,30.5 1 )
set tics out

plot 'outil1' every ::0::30 u 7:xtic(2) notitle lt rgb "blue" fillstyle pattern 2, 'ppm' every ::0::30 u 7 notitle lt rgb "red" fillstyle pattern 2, \
newhistogram at 0, 'outil1' every ::0::30 u 6:x2tic(1) notitle lt rgb "blue", 'ppm' every ::0::30 u 6 notitle lt rgb "red"
plot 'outil1' every ::30::60 u 7:xtic(2) notitle lt rgb "blue" fillstyle pattern 2, 'ppm' every ::30::60 u 7 notitle lt rgb "red" fillstyle pattern 2, \
newhistogram at 0, 'outil1' every ::30::60 u 6:x2tic(1) notitle lt rgb "blue", 'ppm' every ::30::60 u 6 notitle lt rgb "red"
plot 'outil1' every ::60::90 u 7:xtic(2) notitle lt rgb "blue" fillstyle pattern 2, 'ppm' every ::60::90 u 7 notitle lt rgb "red" fillstyle pattern 2, \
newhistogram at 0, 'outil1' every ::60::90 u 6:x2tic(1) notitle lt rgb "blue", 'ppm' every ::60::90 u 6 notitle lt rgb "red"
plot 'outil1' every ::90::120 u 7:xtic(2) notitle lt rgb "blue" fillstyle pattern 2, 'ppm' every ::90::120 u 7 notitle lt rgb "red" fillstyle pattern 2, \
newhistogram at 0, 'outil1' every ::90::120 u 6:x2tic(1) notitle lt rgb "blue", 'ppm' every ::90::120 u 6 notitle lt rgb "red"
plot 'outil1' every ::120::150 u 7:xtic(2) notitle lt rgb "blue" fillstyle pattern 2, 'ppm' every ::120::150 u 7 notitle lt rgb "red" fillstyle pattern 2, \
newhistogram at 0, 'outil1' every ::120::150 u 6:x2tic(1) notitle lt rgb "blue", 'ppm' every ::120::150 u 6 notitle lt rgb "red"

要生成图,您需要 outil1数据文件 ppm数据文件

我对此有一个问题,那就是情节是最后一个与前四个情节的大小不相等.在最后一幅图中,抽芯之间的距离较大,以使其适合整个画布.

The problem that I have with this is the plot is that the last one is not equal in size with the first 4 plots. The distance between the tics is bigger in the last plot in order to make it fit the entire canvas.

有没有一种方法可以使最后一个图与另一个图对齐?例如,使第4个图的126 tic与96 tic对齐.

Is there a way to make the last plot aligned with the other? For example have the 126 tic align with the 96 tic from the 4th plot.

谢谢.

推荐答案

绘制完四个图之后,可以将左边界固定为该矩的值,并根据不同的比例调整右边界从图四到图五.

After you have plotted the four graph, you can fix the left margin to the value it has at this momen, and adapt the right margin according to the different scales from graph four to graph five.

您可以按以下方式计算屏幕坐标中的左边距(即[0:1],其中0表示最左侧的画布边缘,而1表示最右侧的画布边缘),如下所示:

You can calculate the left margin in screen coordinates (i.e. in the range [0:1], with 0 beeing the leftmost canvas edge and 1 the rightmost canvas edge) as follows:

LMARGIN = GPVAL_TERM_SCALE * (0.0 + GPVAL_TERM_XMIN)/GPVAL_TERM_XSIZE

在这里,GPVAL_TERM_SCALE是一个因数,仅在gnuplot 5中可用,但是需要使用此参数来独立于所使用的终端来获得正确的计算.使用gnuplot 4.6时.和pdfcairo端子,此值为20.您可以在脚本中添加一个小的if子句来检查:

Here, GPVAL_TERM_SCALE is a factor, which is available only in gnuplot 5, but is required to get the correct calculations independent on the used terminal. When using gnuplot 4.6. and the pdfcairo terminal, this value is 20. You can put a small if-clause in the script to check this:

if (exists('GPVAL_TERM_SCALE')) SCALE = GPVAL_TERM_SCALE; else SCALE = 20

因此,脚本中的最后一个plot命令应如下所示:

So, the last plot command in your script should look as follows:

if (exists('GPVAL_TERM_SCALE')) SCALE = GPVAL_TERM_SCALE; else SCALE = 20
LMARGIN = SCALE * (0.0 + GPVAL_TERM_XMIN)/GPVAL_TERM_XSIZE
RMARGIN = SCALE * (0.0 + GPVAL_TERM_XMAX)/GPVAL_TERM_XSIZE

set lmargin screen LMARGIN
set rmargin screen LMARGIN + (17.0/32.0)*(RMARGIN - LMARGIN)

plot 'outil1' every ::120::150 u 7:xtic(2) notitle lt rgb "blue" fillstyle pattern 2, 'ppm' every ::120::150 u 7 notitle lt rgb "red" fillstyle pattern 2, \
newhistogram at 0, 'outil1' every ::120::150 u 6:x2tic(1) notitle lt rgb "blue", 'ppm' every ::120::150 u 6 notitle lt rgb "red"

仅通过手动计算要绘制的范围即可得到因子(17.0/32.0).结果是

I got the factor (17.0/32.0) just by manually counting the ranges you want to plot. The result is

这篇关于Gnuplot:多图大小和一个图的缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆