Двухколонный участок в мультиплоте Gnuplot - PullRequest
1 голос
/ 06 июня 2019

Я пытаюсь создать комбинацию мультиплотов (2х2) и одного сюжета. я не уверен что я делаю неправильно, но я не могу понять, как это сделать. Моя попытка:

plot sin(x) title "this should be a single plot"

set multiplot layout 2,2 title "Those are the multiplots"

set title "A!"
plot sin(x)

set title "B!"
plot cos(x) not

set title "C!"
tan(x) title "tan"

set title "D"
tan(0.5*x) not

Неважно, ставлю ли я график после или раньше, но я не могу его визуализировать.

Спасибо.

1 Ответ

2 голосов
/ 06 июня 2019

Вы должны добавить команду заговора перед последними двумя функциями и, возможно, unset multiplot в конце. Это должно работать. Или вы хотите, чтобы один и несколько графиков были видны?

plot sin(x) title "this should be a single plot"

set multiplot layout 2,2 title "Those are the multiplots"

set title "A!"
plot sin(x)

set title "B!"
plot cos(x) not

set title "C!"
plot tan(x) title "tan"

set title "D"
plot tan(0.5*x) not

unset multiplot

Редактировать: (ручная настройка размеров, происхождения и полей)

### Multiplot layout
reset session
set multiplot title "These are five plots"
set ytics 0.5

set margins 5,5,2,8 # l,r,b,t

set size 1,0.5
set origin 0,0.6
set title "top plot"
plot sin(x) title "this should be a single plot"

set size 0.5,0.5

set origin 0,0.3
set title "A!"
plot sin(x)

set origin 0.5,0.3
set title "B!"
plot cos(x)

set origin 0,0
set title "C!"
plot sin(2*x)

set origin 0.5,0
set title "D"
plot cos(2*x)

unset multiplot
### end of code

Результат:

enter image description here

Дополнительно:

Просто для удовольствия, может быть, это пригодится вам или кому-то еще. С помощью нескольких строк у вас будет простой способ установить макет в матрице с несколькими числами, хранящимися в $Layout. Надеюсь, это самоочевидно.

Код:

### easy configurable multiplot layout
reset session

MPRows = 3
MPCols = 4

# row column height width
$Layout <<EOD
1 1 1 1
1 2 2 2
1 4 2 1
2 1 1 1
3 1 1 4
EOD

MPGridX(r,c,h,w) = 1.0/MPCols
MPGridY(r,c,h,w) = 1.0/MPRows
MPSizeX(r,c,h,w) = MPGridX(r,c,h,w)*w
MPSizeY(r,c,h,w) = MPGridY(r,c,h,w)*h
MPOriginX(r,c,h,w) = MPGridX(r,c,h,w)*(c-1)
MPOriginY(r,c,h,w) = 1-MPGridY(r,c,h,w)*(r+h-1)
r(i)=word($Layout[i],1)
c(i)=word($Layout[i],2)
h(i)=word($Layout[i],3)
w(i)=word($Layout[i],4)
SetLayout = 'set origin MPOriginX(r(i),c(i),h(i),w(i)),MPOriginY(r(i),c(i),h(i),w(i)); \
             set size MPSizeX(r(i),c(i),h(i),w(i)),MPSizeY(r(i),c(i),h(i),w(i))'

set multiplot
    set linetype 1 lc rgb "red"
    i=1
    @SetLayout
    plot sin(x)

    i=2
    @SetLayout
    plot cos(x)

    i=3
    @SetLayout
    plot x**3

    i=4
    @SetLayout
    plot x**2

    i=5
    @SetLayout
    plot sin(x)/x
unset multiplot
### end of code

Результат:

enter image description here

...