Gnuplot 多点打印中的行标题

Gnuplot 多点打印中的行标题,gnuplot,Gnuplot,在下图中,每行对应一个不同的大小写/参数。参数从上到下依次为nmesh-2,nmesh-4,nmesh-6,nmesh-8。我想将每个参数写入ylabel或已用时间的左侧。换句话说,我想要一个“行标题”。如果参数名大于,并按经过的时间旋转,也会很好。我的代码包括文件名,但万一我也包括了它 可能最简单的方法是使用多行标签: set ylabel "nmesh-2\n\nElapsed time" 然而,这种解决方案的灵活性相当有限。作为替代方案,可以使用set multiplot和margin

在下图中,每行对应一个不同的大小写/参数。参数从上到下依次为
nmesh-2
nmesh-4
nmesh-6
nmesh-8
。我想将每个参数写入ylabel或
已用时间的左侧。换句话说,我想要一个“行标题”。如果参数名大于,并按
经过的时间旋转,也会很好。我的代码包括文件名,但万一我也包括了它


可能最简单的方法是使用多行标签:

set ylabel "nmesh-2\n\nElapsed time"
然而,这种解决方案的灵活性相当有限。作为替代方案,可以使用
set multiplot
margins
选项,以确保整个multiplot的全局左边距中有足够的“行标题”空间,手动计算屏幕坐标中单个“行标题”的坐标,并在最后一个绘图中渲染它们:

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
}
这将产生:

您可以简单地使用类似于
设置标签
的东西,因为它允许您根据需要设置位置和方向。@Vladimir
设置标签
是此解决方案的基础-上面脚本中唯一稍微复杂一点的事情是计算坐标,将它们放在何处哇,我的坏,我没有深入研究代码,我只是检查了文本部分,对不起
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
}