问题
I have a layout of 3,1 plots using multiplot. All of the three plots have the same scales, so I just want to show one colorbox, on the right margin. However, once I unset the colorbox for the first two plot, the size of the three plot are different. Can anybody tell me how to implement this with the three plots have the same size?
回答1:
You must set a fixed right margin with e.g. set rmargin at screen 0.85
. That sets the right border of the plot at 85% of the image size:
set multiplot layout 3,1
set rmargin at screen 0.85
plot x
plot x
plot x linecolor palette
unset multiplot
set output
Output with 4.6.3:

See also the related question multiplot - stacking 3 graphs on a larger canvas.
Generic solution for fixed margins
If you want a layout with one row and three columns, you must set fixed lmargin
and rmargin
. You can also automate that in some sense, like the following script shows:
init_margins(left, right, gap, cols) = \
sprintf('left_margin = %f; right_margin = %f;', left, right) . \
sprintf('col_count = %d; gap_size = %f;', cols, gap)
set_margins(col) = sprintf('set lmargin at screen %f;', get_lmargin(col)) . \
sprintf('set rmargin at screen %f;', get_rmargin(col));
get_lmargin(col) = (left_margin + (col - 1) * (gap_size + ((right_margin - left_margin)-(col_count - 1) * gap_size)/col_count))
get_rmargin(col) = (left_margin + (col - 1) * gap_size + col * ((right_margin - left_margin)-(col_count - 1) * gap_size)/col_count)
set xlabel 'xlabel'
set ylabel 'ylabel'
eval(init_margins(0.1, 0.9, 0.07, 3))
set multiplot
eval(set_margins(1))
plot x
unset ylabel
eval(set_margins(2))
plot x
eval(set_margins(3))
plot x linecolor palette
unset multiplot
Evaluating the string returned by init_margins
sets some variables, which are later used to the the left and right margin of the plot in the n-th column. left
is the left most margins, which contains e.g. a label, right
is the right most margins, which accounts for e.g. a colorbox
, gap
is the separation between the borders of two plots, and cols
is the number of columns.
Result is:

来源:https://stackoverflow.com/questions/21085177/gnuplot-multiplot-with-one-colorbox