Reputation: 6149
In the figure below, each row corresponds to a different case/parameter. Parameters from top to bottom are nmesh-2
, nmesh-4
, nmesh-6
, nmesh-8
. I would like to write each parameter to the left of ylabel or Elapsed time
. In other words, I want a "row title". It would also be nice if parameter name was bigger than and rotated as Elapsed time
. My code includes filenames but in case I included it as well.
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
}
Upvotes: 1
Views: 139
Reputation: 13087
Perhaps the easiest approach to do this would be to use a multiline y label:
set ylabel "nmesh-2\n\nElapsed time"
However, the flexibility of this solution is rather limited. As an alternative, one might use set multiplot
with the margins
option in order to make sure that there is enough space for the "row titles" in the global left margin of the entire multiplot, calculate the coordinates of the individual "row titles" in screen coordinates manually and render them within the last plot:
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
}
Upvotes: 1