Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only 1 y label in GNUplot multiplot

Tags:

gnuplot

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.

like image 523
RoflcoptrException Avatar asked Jun 28 '13 15:06

RoflcoptrException


3 Answers

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.

like image 151
andyras Avatar answered Oct 22 '22 12:10

andyras


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).

like image 3
Fabian Claremont Avatar answered Oct 22 '22 12:10

Fabian Claremont


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.