Gnuplot 减少绘图中的空白,使图形以最佳方式拟合

Gnuplot 减少绘图中的空白,使图形以最佳方式拟合,gnuplot,Gnuplot,我正在用11个图形绘制多点图。我给出了下面使用的代码: #!/usr/bin/gnuplot ######################################################################################## #OUTPUT set size 1.0, 1.0 #POSTCRIPT set term postscript landscape enhanced color set output "radial_distribut

我正在用11个图形绘制多点图。我给出了下面使用的代码:

#!/usr/bin/gnuplot

########################################################################################
#OUTPUT

set size 1.0, 1.0

#POSTCRIPT
set term postscript landscape enhanced color 
set output "radial_distribution_function.ps"    #

#set terminal postscript portrait enhanced color dashed "Helvetica" 8 
#set output "time-density-profile-maltose.ps"

#PNG
#set terminal pngcairo size 650,450 enhanced dash
#set output "multi-plot_gauche_bcMalto-chain2-thermo.png"

# WXT
#set terminal wxt size 900,450 enhanced font 'Arial,10' dashed persist


#set style line 4 lt 4 lw 10    # Please DISABLE pause -1 
#########################################################################
set style line 1 lt 1 lc rgb "#FFB6C1"  lw 2.0  
set style line 2 lt 1 lc rgb "black"    lw 2.0 
set style line 3 lt 1 lc rgb "green"    lw 2.0 
set style line 4 lt 1 lc rgb "blue"     lw 2.0 
set style line 5 lt 1 lc rgb "#8B008B"  lw 2.0
set style line 6 lt 1 lc rgb "yellow"   lw 2.0
#########################################################################


### START MARCRO
set macro
#ylabelFONT="font 'Arial,16'"
labelFONT="font 'Arial,12'"
scaleFONT="font 'Arial,12'"
keyFONT="font 'Arial,14'"
#graph="using 1:2 with lines lw 1   "
scaleFONT2="font 'Arial,11'"
### END MACRO


set key font ",8"
set key spacing 0.7
unset key
set autoscale                           # scale axes automatically
set xtic auto                        @scaleFONT     # set xtics automatically
set ytic auto                        @scaleFONT     # set ytics automatically
set xlabel "Distance (Angstrom)"    @labelFONT
set ylabel "g(r)"           @labelFONT
set xrange [0:10]
set yrange [0:5]
#set title "Density profile for isomaltose"


set multiplot layout 4,3 title ""


# PLOT_1
set label "(a) O11" at 1.5, 4   @labelFONT
plot    "maltoLyo12per-ddm_O11-wat_O.dat"   using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
    "maltoLyo23per-ddm_O11-wat_O.dat"   using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
    "bcmLyo25perR-BMR_O11-wat_O.dat"    using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
    "bcmLyo25perS-BCS_O11-wat_O.dat"    using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
    "bchainRS25per-BMR_O11-wat_O.dat"   using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
    "bchainRS25per-BMS_O11-wat_O.dat"   using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"


# PLOT_2
unset label
set label "(b) O12" at 1.5, 4   @labelFONT
plot    "maltoLyo12per-ddm_O12-wat_O.dat"   using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
    "maltoLyo23per-ddm_O12-wat_O.dat"   using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
    "bcmLyo25perR-BMR_O12-wat_O.dat"    using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
    "bcmLyo25perS-BCS_O12-wat_O.dat"    using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
    "bchainRS25per-BMR_O12-wat_O.dat"   using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
    "bchainRS25per-BMS_O12-wat_O.dat"   using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"

# PLOT_3
unset label
set label "(c) O13" at 1.5, 4   @labelFONT 
plot    "maltoLyo12per-ddm_O13-wat_O.dat"   using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
    "maltoLyo23per-ddm_O13-wat_O.dat"   using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
    "bcmLyo25perR-BMR_O13-wat_O.dat"    using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
    "bcmLyo25perS-BCS_O13-wat_O.dat"    using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
    "bchainRS25per-BMR_O13-wat_O.dat"   using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
    "bchainRS25per-BMS_O13-wat_O.dat"   using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"

# PLOT_4
unset label
set label "(d) O14" at 1.5, 4   @labelFONT
plot    "maltoLyo12per-ddm_O14-wat_O.dat"   using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
    "maltoLyo23per-ddm_O14-wat_O.dat"   using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
    "bcmLyo25perR-BMR_O14-wat_O.dat"    using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
    "bcmLyo25perS-BCS_O14-wat_O.dat"    using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
    "bchainRS25per-BMR_O14-wat_O.dat"   using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
    "bchainRS25per-BMS_O14-wat_O.dat"   using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"



# PLOT_5
unset label
set label "(e) O15" at 1.5, 4   @labelFONT 
plot    "maltoLyo12per-ddm_O15-wat_O.dat"   using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
    "maltoLyo23per-ddm_O15-wat_O.dat"   using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
    "bcmLyo25perR-BMR_O15-wat_O.dat"    using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
    "bcmLyo25perS-BCS_O15-wat_O.dat"    using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
    "bchainRS25per-BMR_O15-wat_O.dat"   using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
    "bchainRS25per-BMS_O15-wat_O.dat"   using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"

# PLOT_6
unset label
set label "(f) O16" at 1.5, 4   @labelFONT
plot    "maltoLyo12per-ddm_O16-wat_O.dat"   using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
    "maltoLyo23per-ddm_O16-wat_O.dat"   using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
    "bcmLyo25perR-BMR_O16-wat_O.dat"    using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
    "bcmLyo25perS-BCS_O16-wat_O.dat"    using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
    "bchainRS25per-BMR_O16-wat_O.dat"   using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
    "bchainRS25per-BMS_O16-wat_O.dat"   using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"



# PLOT_7
unset label
set label "(g) O22" at 1.5, 4   @labelFONT 
plot    "maltoLyo12per-ddm_O22-wat_O.dat"   using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
    "maltoLyo23per-ddm_O22-wat_O.dat"   using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
    "bcmLyo25perR-BMR_O22-wat_O.dat"    using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
    "bcmLyo25perS-BCS_O22-wat_O.dat"    using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
    "bchainRS25per-BMR_O22-wat_O.dat"   using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
    "bchainRS25per-BMS_O22-wat_O.dat"   using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"

# PLOT_8
unset label
set label "(h) O23" at 1.5, 4   @labelFONT
plot    "maltoLyo12per-ddm_O23-wat_O.dat"   using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
    "maltoLyo23per-ddm_O23-wat_O.dat"   using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
    "bcmLyo25perR-BMR_O23-wat_O.dat"    using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
    "bcmLyo25perS-BCS_O23-wat_O.dat"    using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
    "bchainRS25per-BMR_O23-wat_O.dat"   using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
    "bchainRS25per-BMS_O23-wat_O.dat"   using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"



# PLOT_9
unset label
set label "(i) O24" at 1.5, 4   @labelFONT 
plot    "maltoLyo12per-ddm_O24-wat_O.dat"   using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
    "maltoLyo23per-ddm_O24-wat_O.dat"   using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
    "bcmLyo25perR-BMR_O24-wat_O.dat"    using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
    "bcmLyo25perS-BCS_O24-wat_O.dat"    using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
    "bchainRS25per-BMR_O24-wat_O.dat"   using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
    "bchainRS25per-BMS_O24-wat_O.dat"   using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"

# PLOT_10
unset label
set label "(j) O25" at 1.5, 4   @labelFONT
plot    "maltoLyo12per-ddm_O25-wat_O.dat"   using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
    "maltoLyo23per-ddm_O25-wat_O.dat"   using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
    "bcmLyo25perR-BMR_O25-wat_O.dat"    using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
    "bcmLyo25perS-BCS_O25-wat_O.dat"    using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
    "bchainRS25per-BMR_O25-wat_O.dat"   using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
    "bchainRS25per-BMS_O25-wat_O.dat"   using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"



# PLOT_11
unset label
set label "(k) O26" at 1.5, 4   @labelFONT
unset key 
plot    "maltoLyo12per-ddm_O26-wat_O.dat"   using 1:2 w l ls 1 title "{/Symbol b}Mal-C_{12}12%H_{2}O",\
    "maltoLyo23per-ddm_O26-wat_O.dat"   using 1:2 w l ls 2 title "{/Symbol b}Mal-C_{12}23%H_{2}O",\
    "bcmLyo25perR-BMR_O26-wat_O.dat"    using 1:2 w l ls 3 title "{/Symbol b}Mal-C_{12}C_{8}(R)25%H_{2}O",\
    "bcmLyo25perS-BCS_O26-wat_O.dat"    using 1:2 w l ls 4 title "{/Symbol b}Mal-C_{12}C_{8}(S)25%H_{2}O",\
    "bchainRS25per-BMR_O26-wat_O.dat"   using 1:2 w l ls 5 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(R)25%H_{2}O",\
    "bchainRS25per-BMS_O26-wat_O.dat"   using 1:2 w l ls 6 title "{/Symbol b}Mal-C_{12}C_{8}(RS)(S)25%H_{2}O"

unset multiplot
我得到的图表显示在这里

我从图表中注意到,图表之间有很多空白。例如,在图(a)和(b)之间,以及在图(a)和(d)之间。我想缩小它们之间的空间,使图形变大一点

我应该做什么来减少空间和优化图形大小

提前谢谢。

好的,让我们开始:)

首先,您的脚本和数据文件的命名非常适合迭代。因此,您可以使用占位符
%s
定义文件名模板列表,该占位符稍后将被实际参数替换

因此,首先对不同的
O11
O12
等值进行迭代,并为每个值生成一个新的绘图。然后在文件名上有一个绘图,所有文件名都放在一个绘图中

使用
set linetype
定义颜色可使用自动线型增量

现在谈谈你的实际问题:

我认为最好的选择是稍微校正标签的偏移量,例如使用

set ylabel "g(r)" offset 1,0  @labelFONT
它将ylabel相对于自动选择的位置向右移动一个字符单位。这会给你一个更大的图表

如果这还不够,您必须开始手动设置边距。首先,我将只更改顶部和右侧的页边距。用例如

set tmargin 0
set rmargin 0
顶部和右侧边距将放置在各自面板的边界处。例如,
set rmargin 0.5
将右边距设置为半个字符宽度。你必须玩弄这些价值观

这是一个简短的脚本。请注意,我无法测试它,因为我没有数据文件。我希望我没有犯任何错误:)


谢谢你的帮助。我尝试了你修改过的代码。成功了。但我能看到的是标签(b),(c)和其他标签实际上从标签(b)开始彼此重叠。此外,我希望图例可能放置在右下角。(图(k)旁边)。因为循环对我来说是新的,所以我不得不问这个问题。谢谢。关于标签,我忘了添加一个显式标签标签
设置标签1…
,以便在每个绘图中覆盖标签。关于钥匙,我以后要考虑;)
#!/usr/bin/gnuplot

set term postscript landscape enhanced color 
set output "radial_distribution_function.ps"    #

#########################################################################
set linetype 1 lt 1 lc rgb "#FFB6C1"  lw 2.0  
set linetype 2 lt 1 lc rgb "black"    lw 2.0 
set linetype 3 lt 1 lc rgb "green"    lw 2.0 
set linetype 4 lt 1 lc rgb "blue"     lw 2.0 
set linetype 5 lt 1 lc rgb "#8B008B"  lw 2.0
set linetype 6 lt 1 lc rgb "yellow"   lw 2.0
#########################################################################

set macro
labelFONT="font 'Arial,12'"
scaleFONT="font 'Arial,12'"
keyFONT="font 'Arial,14'"
scaleFONT2="font 'Arial,11'"

unset key
set autoscale                           # scale axes automatically
set xtic auto                        @scaleFONT     # set xtics automatically
set ytic auto                        @scaleFONT     # set ytics automatically
set xlabel "Distance (Angstrom)"     @labelFONT
set ylabel "g(r)"  offset 1,0        @labelFONT
set xrange [0:10]
set yrange [0:5]

file_tmpls = "maltoLyo12per-ddm_%s-wat_O.dat ".\
             "maltoLyo23per-ddm_%s-wat_O.dat ".\
             "bcmLyo25perR-BMR_%s-wat_O.dat ".\
             "bcmLyo25perS-BCS_%s-wat_O.dat ".\
             "bchainRS25per-BMR_%s-wat_O.dat ".\
             "bchainRS25per-BMS_%s-wat_O.dat "

par = "O11 O12 O13 O14 O15 O16 O22 O23 O24 O25 O26"
labels = "a b c d e f g h i j k"
label_tmpl = "(%s) %s"

# You must optimize the values, which are given in units of character widths (or heights)
set tmargin 0.5
set rmargin 0.5
#set lmargin 2
#set bmargin 2

set multiplot layout 4,3 title ""

do for [i=1:words(par)] {

    set label 1 sprintf("(%s) %s", word(labels, i), word(par, i)) at 1.5, 4 @labelFONT

    plot for [f in file_tmpls] sprintf(f, word(par, i)) using 1:2 w l

}
unset multiplot