我正在使用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)之间。我想减少它们之间的空间,使图形更大。
我应该做些什么来减少空间并优化图表大小。
提前致谢。
答案 0 :(得分:1)
好的,让我们开始:)
首先,您的脚本和数据文件的命名非常适合迭代。因此,您可以使用占位符%s
定义文件名模板列表,该占位符稍后将替换为实际参数。
因此,您首先对不同的O11
,O12
等值进行迭代,并为每个值生成一个新的图。然后,您对文件名进行plot for
次迭代,这些文件名都放在一个图中。
使用set linetype
定义颜色可以使用自动线型增量。
现在问你的实际问题:
我认为最好的选择是稍微纠正标签的偏移,例如与
set ylabel "g(r)" offset 1,0 @labelFONT
将ylabel相对于自动选择的位置向右移动一个字符单元。这应该会给你一个更大的图表。
如果这还不够,您必须开始手动设置边距。我首先只改变顶部和右边距。例如。
set tmargin 0
set rmargin 0
顶部和右边距将放置在相应面板的边界处。用例如set rmargin 0.5
右边距设置为半字符宽度。你必须使用这些值。
这是一个缩短的脚本。请注意,我无法测试它,因为我没有数据文件。我希望我没有犯错误:))
#!/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