Vijay
Vijay

Reputation: 985

generating one legend in multiplot and and placing it at the last column and last row

I am trying to arrange several plots with histograms in a multiplot mode. I have successfully plotted them. (Please see the attached pic)

plot.

But I have a problem with plotting the legend (or key).

I want the legend to be at the middle of the last row and the most right column in the multiplot (please see the attached plot).

I have tried to plot the legend but no avail. To have a better understanding of what I did, I have provided the whole script on which I am working.

Hope I get some help to draw the legend and place that at last column and last row.

#!/usr/bin/gnuplot

#########################################################################################
set terminal postscript eps size 7.8,6.8 enhanced color font 'Helvetica,20'
set output 'yy_HB_all_Chap6_LYOsystems.eps'
#########################################################################################

set macro
labelFONT="font 'Helvetica,24'"
labelFONTin="font 'Helvetica,18'"
scaleFONT="font 'Helvetica,16'"
scaleFONTx="font 'Helvetica,15'"

keyFONT="font 'Helvetica,24'"
set key spacing 3.5 samplen 3  @keyFONT

#########################################################################################


set xtics @scaleFONT
set ytics @scaleFONT

set xlabel "Oxygen"         @labelFONT
set ylabel "Hydrogen Bond"  @labelFONT  offset 2.2,0
#set label "Hydrogen Bonds" at -2.0,0.35 rotate by 90 right         @labelFONT
#########################################################################################33

set style histogram rowstacked
set style data histograms
set boxwidth 0.75 absolute 
set style fill solid 1.00 noborder

#set boxwidth 0.8
#set style fill transparent solid 0.75 noborder
set yrange [0:2.5]
set xrange [0:12]


set multiplot layout 3,2 title ""

##PLOT_1 (1,1)
set label "(a) {/Symbol-Oblique b}Mal-C_{12}(12%wat)" at 1, 2.2     @labelFONTin
plot "HB-data-maltoLyo12per.dat" using 2 t "Lipid-lipid" lc rgb "#191970", '' using 3:xticlabels(5) t "Water-lipid" lc rgb "#6495ED"


###PLOT_2 (1,2)
unset label
set label "(b) {/Symbol-Oblique b}Mal-C_{12}(23%wat)" at 1, 2.2     @labelFONTin
plot "HB-data-maltoLyo23per.dat" using 2 t "Lipid-lipid" lc rgb "#191970", '' using 3:xticlabels(5) t "Water-lipid" lc rgb "#6495ED"


###PLOT_3 (2,1)
unset label
set label "(c) {/Symbol-Oblique b}Mal-C_{12}C_{8}({/Helvetica-Italic R}) " at 1, 2.2    @labelFONTin
plot "HB-data-bcmLyo25perR.dat" using 2 t "Lipid-lipid" lc rgb "#191970", '' using 3:xticlabels(5) t "Water-lipid" lc rgb "#6495ED"


###PLOT_4 (2,2)
unset label
set label "(d) {/Symbol-Oblique b}Mal-C_{12}C_{8}({/Helvetica-Italic S}) " at 1, 2.2    @labelFONTin
plot "HB-data-bcmLyo25perS.dat" using 2 t "Lipid-lipid" lc rgb "#191970", '' using 3:xticlabels(5) t "Water-lipid" lc rgb "#6495ED"


###PLOT_4 (3,1)
unset label
set label "(e) {/Symbol-Oblique b}Mal-C_{12}C_{8}({/Helvetica-Italic RS}) " at 1, 2.2   @labelFONTin
plot "HB-data-bcmLyo25perRS.dat" using 2 t "Lipid-lipid" lc rgb "#191970", '' using 3:xticlabels(5) t "Water-lipid" lc rgb "#6495ED"

######################################################################################################

#set size 0.3,0.3
#set origin 0.70,0.6
set bmargin at screen 0
set key center @keyFONT
set border 0 
unset xlabel
unset ylabel
unset label
unset tics
set format x ""
set format y ""

set yrange [0:1]

plot    2 ls 1 title "Lipid-lipid",\
    2 ls 2 title "Water-lipid"
######################################################################################################
unset multiplot

Upvotes: 3

Views: 3425

Answers (1)

Joce
Joce

Reputation: 2342

You can do this with a trick:

unset key

just after the set multiplot command, so no key is displayed for the first plots. Then, before the last one, issue a command that will restore the key and put it in the right place, that is, outside of the current plot:

###PLOT_4 (3,1)
set key at graph 1.5,screen 0.5 center center

Upvotes: 2

Related Questions