删除gnuplot多色时的空白间隙

Pea*_*ful 13 gnuplot

我在gnuplot中使用multiplot在单个图中插入四个图.我的代码看起来像这样:

set term postscript eps enhanced color
set xlabel 'i'
set ylabel 'j'
set xtics 20
set ytics 20
set xlabel font ",20"
set ylabel font ",20"
set pm3d map
set pm3d corners2color c1
set out "Rulkovpattern.eps"
set multiplot layout 2,2
set title "(a)"
set size square 0.55,0.55
spl 'patternD0pt02.dat' notitle
set title "(b)"
set size square 0.55,0.55
spl 'patternD0pt04.dat' notitle
set size square 0.55,0.55
set title "(c)"
spl 'patternD0pt06.dat' notitle
set size square 0.55,0.55
set title "(d)"
spl 'patternD0pt08.dat' notitle
unset multiplot
set out
set term wxt
Run Code Online (Sandbox Code Playgroud)

这会生成以下图片: 模式

但是在这张照片中,中间有很多空白.我想让这个空间消失或至少尽可能减少它.我怎么能通过修改我的代码来做到这一点?

提前致谢

Chr*_*oph 20

获得正确的边距multiplot有点单调乏味,特别是在使用时set pm3d map,边距相当大.

从5.0版开始

自5.0版以来,multiplot有选项marginsspacing.

margins取四个数字set multiplot margins <left>,<right>,<bottom>,<top>,这给出了多时间布局周围固定的整体边距.spacing取两个数字set multiplot spacing <xspacing>,<yspacing>,它们给出两行(<yspacing>)或两列(<xspacing>)之间的距离.

set terminal pngcairo size 800,600 background rgb '#bbbbbb'
set output 'foobar.png'

set multiplot layout 2,2 \
              margins 0.1,0.98,0.1,0.98 \
              spacing 0.08,0.08

set ylabel 'ylabel'
plot x

unset ylabel
plot 2*x

set ylabel 'ylabel'
set xlabel 'xlabel'
plot 3*x

unset ylabel
plot 4*x
unset multiplot
Run Code Online (Sandbox Code Playgroud)

结果(使用5.0rc1):

在此输入图像描述

早期版本,仅保留完整性

要使用gnuplot 4.x实现相同的功能,您必须手动执行计算或定义一些函数,如下面的示例所示.这应该是非常普遍可用的.

您可以将所有常规内容放在配置文件中,例如multiplot.gp包含函数的配置文件

init_margins(left, right, bottom, top, dx, dy, rows, cols) = \
  sprintf('left_margin = %f; right_margin = %f; top_margin = %f; bottom_margin = %f; ', left, right, top, bottom) . \
  sprintf('col_count = %d; row_count = %d; gap_size_x = %f; gap_size_y = %f', cols, rows, dx, dy)

get_lmargin(col) = (left_margin + (col - 1) * (gap_size_x + ((right_margin - left_margin)-(col_count - 1) * gap_size_x)/col_count))
get_rmargin(col) = (left_margin + (col - 1) * gap_size_x + col * ((right_margin - left_margin)-(col_count - 1) * gap_size_x)/col_count)
get_tmargin(row) = (top_margin  - (row - 1) * gap_size_y - (row-1) * ((top_margin - bottom_margin  - gap_size_y * row_count) / row_count))
get_bmargin(row) = (top_margin  - (row - 1) * gap_size_y -  row    * ((top_margin - bottom_margin  - gap_size_y * row_count) / row_count))
set_margins(col, row) = \
  sprintf('set lmargin at screen %f;', get_lmargin(col)) . \
  sprintf('set rmargin at screen %f;', get_rmargin(col)) . \
  sprintf('set tmargin at screen %f;', get_tmargin(row)) . \
  sprintf('set bmargin at screen %f;', get_bmargin(row))         
Run Code Online (Sandbox Code Playgroud)

然后是主文件

set terminal pngcairo size 800,600 background rgb '#bbbbbb'
set output 'foobar2.png'

load 'multiplot.gp'

eval(init_margins(0.1, 0.98, 0.1, 0.98, 0.08, 0.08, 2, 2))    
set multiplot

eval(set_margins(1,1))
set ylabel 'ylabel'
plot x

eval(set_margins(2,1))
unset ylabel
plot 2*x

eval(set_margins(1,2))
set ylabel 'ylabel'
set xlabel 'xlabel'
plot 3*x

eval(set_margins(2,2))
unset ylabel
plot 4*x
unset multiplot
Run Code Online (Sandbox Code Playgroud)

结果(使用4.6.4):

在此输入图像描述

  • @Bernhard :) 对此感到抱歉,这有点不公平:我为 gnuplot 实现了此功能,所以我是第一个知道它的人。另一个“替代”部分取自我的论文脚本。 (2认同)