9

I use gnu plot to draw a multiplot and in my script I set the y label like that:

set ylabel "foobar"

Now every plot in the multiplot has a dedicated y label on their y axis. However, I would like to have only one y label for all the plots in the multiplot and center that label also on the common y axis. How can I do that? The multiplot layout I use is a 7.1 So all the plots have the same y axis.

4

4 回答 4

6

The simplest way is to make the first plot, then turn off the y label:

set ylabel 'foo'
set multiplot

plot 'data1.dat'

unset ylabel

plot 'data2.dat'
plot ...

unset multiplot

This will make the x-dimension of the first plot different from that of all the other plots, so you may have to play with the margins if you want all the plots the exact same size.

于 2013-06-28T16:01:18.560 回答
3

Plot the individual panels of reduced size without labels but with border, tics and title, then define a full-sized panel with labels but without border, tics and title.You may have to plot a dummy function (1/0).

于 2013-07-03T15:29:20.410 回答
2

Global label workaround

This is not ideal, but if you desperate like me, you can use a rotated global label + larger left margins:

#!/usr/bin/env gnuplot
label_label_size = 14
set terminal png
set output "gnuplot.png"
set multiplot layout 2,1 title "Multiplot with one ylabel" font ",18"
set lmargin 10
set label "My y-label" at screen 0.05,0.5 center front rotate \ 
  font "," . label_label_size
plot sin(x)
set xlabel 'My x-label' font "," . label_label_size
plot cos(x)

enter image description here

Here is a realistic application that motivated me to do this: Heap vs Binary Search Tree (BST)

Tested in gnuplot 5.2 patchlevel 6, Ubuntu 19.04.

于 2019-06-28T08:19:21.670 回答
0

This is basically the suggestion from Fabian Claremont's answer, but (for beginners) put into code and visualized. Actually, Ciro Santilli's solution is even shorter.

Tested with gnuplot 5.2. For gnuplot 4.6 (the time of OP's question), replace reset session with reset and set margin 8,-1,1-1 with set lmargin 8 and set bmargin 1.

Code:

### Multiplot with single y-label
reset session
unset key
set sample 500

set multiplot layout 7,1
    unset ylabel
    set linetype 1 lc rgb "red"
    set margins 8,-1,1,-1    # left, right, bottom, top (-1=auto)
    set ytic 1.0
    set title "Plot 1" offset 0,-1
    plot sin(1*x)
    set title "Plot 2" offset 0,-1
    plot sin(2*x)
    set title "Plot 3" offset 0,-1
    plot sin(3*x)
    set title "Plot 4" offset 0,-1
    plot sin(4*x)
    set title "Plot 5" offset 0,-1
    plot sin(5*x)
    set title "Plot 6" offset 0,-1
    plot sin(6*x)
    set title "Plot 7" offset 0,-1
    plot sin(7*x)

    set lmargin -1   # automatic lmargin
    unset title
    set origin 0,0
    set size 1,1
    set border 0
    unset tics
    set ylabel "This is a centered y-label"
    plot [][0:1] -1     # plot a dummy line out of range
unset multiplot
### end of code

Result:

enter image description here

于 2019-06-28T23:07:21.823 回答