Подтвердить что ты не робот

Удаление пробела в множителе gnuplot

Я использую multipot в gnuplot для вставки четырех графиков в один рисунок. Мой код выглядит следующим образом:

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

Это создает следующее изображение: patterns

Но на этой картинке в середине много свободного места. Я хотел бы, чтобы это пространство исчезло или, по крайней мере, сделало его как можно более минимальным. Как я могу это сделать, изменив код?

Заранее спасибо

4b9b3361

Ответ 1

Получение полей с помощью multiplot немного утомительно, особенно при использовании set pm3d map, который имеет довольно большие поля.

Так как первый релиз релиза версии 5.0 уже вышел, я хотел бы упомянуть новые опции margins и spacing multiplot.

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

Результат (с 5.0rc1):

enter image description here

Чтобы добиться того же, что и с 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))         

Тогда главный файл

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

В результате (используя 4.6.4):

enter image description here

Ответ 2

В multiplot с помощью set lmargin, set rmargin, set bmargin и set tmargin, для левого, правого, нижнего верхнего поля вокруг вашего графика вы лучше всего сможете управлять позиционированием ваших графиков. По моему опыту это дает вам немного больше свободы, чем опция layout, которую вы используете сейчас.

Хороший пример того, как это сделать для одного графика, можно найти здесь: http://www.gnuplotting.org/multiplot-placing-graphs-next-to-each-other/

Другой подход - определить функции для задания поля, что проще, если все ваши графики имеют одинаковый размер, см. http://www.sciencetronics.com/greenphotons/?p=570

Ответ 3

Если все имеют одинаковые xlabel и ylabel, вы можете использовать этот

set terminal postscript eps enhanced color
set output 'YOUR_GRAPH.eps'

L = 0.14
R = 0.95

TOP=0.98
DY = 0.29

set multiplot

set offset 0,0,graph 0.05, graph 0.05

set ylabel 'XLABEL' offset 1
set xlabel 'YLABEL'


set tmargin at screen TOP-1.65*DY
set bmargin at screen TOP-3*DY
set lmargin at screen R-6*L
set rmargin at screen R-3*L
plot "YOUR_DATA.dat" title"TITLE 1" 

set ytics format ''
unset ylabel
set lmargin at screen R-3*L
set rmargin at screen R
plot "YOUR_DATA2.dat" title"TITLE 2"


####################################################################

set format y "%.2f"
set ylabel 'd' offset 1
set tmargin at screen TOP
set bmargin at screen TOP-1.35*DY

set lmargin at screen R-6*L
set rmargin at screen R-3*L
plot "YOUR_DATA3.dat" title"TITLE 3"

set ytics format ''
unset ylabel
set lmargin at screen R-3*L
set rmargin at screen R
plot "YOUR_DATA4.dat" title"TITLE 4"