多图中的行标题

时间:2018-10-16 10:17:36

标签: gnuplot

在下图中,每一行对应一个不同的大小写/参数。从上到下的参数为nmesh-2nmesh-4nmesh-6nmesh-8。我想将每个参数写到ylabel或Elapsed time的左侧。换句话说,我想要一个“行标题”。如果参数名称大于并旋转为Elapsed time,那也很好。我的代码包含文件名,但如果我也包含文件名。

enter image description here

set key autotitle columnhead
set boxwidth 0.5
set style fill transparent solid
set nokey

set terminal wxt size 1900,990
set multiplot layout 4, 7
set xtics rotate by -45

np = "8 12 16 20 24 28 32"
do for [IDX=1:7] {
    if (IDX == 1) {
        set ylabel 'Elapsed time'
    }
    else {
        unset ylabel
    }
    set title sprintf("np-%s", word(np, IDX))
    plot sprintf("run-1/np-%s/nmesh-2/load-estim-0/hole-cut-implicit/cpupertask-3/ncell-11/dominant-0.dat", word(np, IDX)) u 2:xtic(1) with boxes
}
set notitle
do for [IDX=1:7] {
    if (IDX == 1) {
        set ylabel 'Elapsed time'
    }
    else {
        unset ylabel
    }
    plot sprintf("run-1/np-%s/nmesh-4/load-estim-0/hole-cut-implicit/cpupertask-3/ncell-11/dominant-0.dat", word(np, IDX)) u 2:xtic(1) with boxes
}
do for [IDX=1:7] {
    if (IDX == 1) {
        set ylabel 'Elapsed time'
    }
    else {
        unset ylabel
    }
    plot sprintf("run-1/np-%s/nmesh-6/load-estim-0/hole-cut-implicit/cpupertask-3/ncell-11/dominant-0.dat", word(np, IDX)) u 2:xtic(1) with boxes
}
do for [IDX=1:7] {
    if (IDX == 1) {
        set ylabel 'Elapsed time'
    }
    else {
        unset ylabel
    }
    plot sprintf("run-1/np-%s/nmesh-10/load-estim-0/hole-cut-implicit/cpupertask-3/ncell-11/dominant-0.dat", word(np, IDX)) u 2:xtic(1) with boxes
}

1 个答案:

答案 0 :(得分:0)

也许最简单的方法是使用多行y标签:

set ylabel "nmesh-2\n\nElapsed time"

但是,此解决方案的灵活性相当有限。另一种选择是,可以将set multiplotmargins选项一起使用,以确保整个多图的全局左边界中的“行标题”有足够的空间,计算屏幕上的各个“行标题”手动进行坐标处理,并在最后一个绘图中进行渲染:

set terminal pngcairo size 1900,990 enhanced
set output 'fig.png'

numOfRows = 4
marginLeft = 0.1
marginRight = marginLeft/2
marginV = 0.1
plotSpacing = marginV / 2
plotHeight = (1. - 2*marginV - (numOfRows-1)*plotSpacing) / numOfRows
labelPos(i) = 1. - (marginV + plotHeight/2 + i*(plotHeight + plotSpacing))

params = "nmesh-2 nmesh-4 nmesh-6 nmesh-8"

set multiplot layout numOfRows,7 margins marginLeft,1-marginRight,marginV,1-marginV spacing plotSpacing

set key autotitle columnhead
set boxwidth 0.5
set style fill transparent solid
set nokey

set xtics rotate by -45

np = "8 12 16 20 24 28 32"
do for [IDX=1:7] {
    if (IDX == 1) {
        set ylabel 'Elapsed time'
    }
    else {
        unset ylabel
    }
    set title sprintf("np-%s", word(np, IDX))
    plot sin(x) w l
}
set notitle
do for [IDX=1:7] {
    if (IDX == 1) {
        set ylabel 'Elapsed time'
    }
    else {
        unset ylabel
    }
    plot sin(x) w l
}
do for [IDX=1:7] {
    if (IDX == 1) {
        set ylabel 'Elapsed time'
    }
    else {
        unset ylabel
    }
    plot sin(x) w l
}


do for [IDX=1:7] {
    if (IDX == 1) {
        set ylabel "Elapsed time"
    }
    else {
        unset ylabel
    }

    if (IDX == 7) {
      do for [j=1:4] {
        set label word(params, j) at screen marginLeft/2, screen labelPos(j-1) offset char -2, 0 center rotate by 90 font "Arial,16"
      }
    }
    plot sin(x) w l
}

这应该产生: enter image description here