Gnuplot horizontal key

I am using gnuplot in a multiplexer environment. I want to have only one key block (which is not a problem) that I want to put horizontally under the graphs.

Nice Plot1 | Nice Plot2 Nice Plot3 | Nice Plot4 the keybox 

It seems that the total size of the keyword cannot exceed the width of the corresponding graph (so here it is equal to half the size of the screen). This causes a row to be returned in the key box, which I do not want.

Is there any way around this?

Thanks.

Edit: Script added. (the key is on 3 lines)

 set terminal epslatex color set output 'Plot.tex' set multiplot set xrange [0:0.8] set key box set key reverse horizontal maxcols 10 samplen 0.5 spacing 1 #set key font ",9" set key at screen 0.9,0.15 set size 0.5,0.5 set origin 0,0 set lmargin 4 set bmargin 3 set rmargin 0 set tmargin 0 set xtics nomirror set ytics nomirror plot x with lines lt 1 lw 4 lc rgb "red" title 'Median',\ x with lines lw 4 lc rgb "blue" title '$ F,F^{-1}$',\ x with lines lw 4 lc rgb "magenta" title '$ F,\Gamma^\mathcal{P}$',\ x with lines lw 4 lc rgb "orange" title '$\Lambda_\text{MI}$',\ x with lines lt 1 lw 4 lc rgb "green" title '$k$-NN' # # Plot n°2 # set size 0.5,0.5 set origin 0,0.5 set xrange [0:0.8] set key off set title '' set lmargin 4 set bmargin 3 set rmargin 0 set tmargin 0 set xtics nomirror set ytics nomirror plot x with lines lt 1 lw 4 lc rgb "red" title 'Median',\ x with lines lw 4 lc rgb "blue" title '$ F,F^{-1}$',\ x with lines lw 4 lc rgb "magenta" title '$ F,\Gamma^\mathcal{P}$',\ x with lines lw 4 lc rgb "orange" title '$\Lambda_\text{MI}$',\ x with lines lt 1 lw 4 lc rgb "green" title 'KNN',\ x with lines lt 1 lw 4 lc rgb "black" title 'Ground Truth' set size 0.5,0.5 set origin 0.5,0 set xrange [0:0.8] set key off set title '' set lmargin 4 set bmargin 3 set rmargin 0 set tmargin 0 set xtics nomirror set ytics nomirror plot x with lines lt 1 lw 4 lc rgb "red" title 'Median',\ x with lines lw 4 lc rgb "blue" title '$ F,F^{-1}$',\ x with lines lw 4 lc rgb "magenta" title '$ F,\Gamma^\mathcal{P}$',\ x with lines lw 4 lc rgb "orange" title '$\Lambda_\text{MI}$',\ x with lines lt 1 lw 4 lc rgb "green" title 'KNN',\ x with lines lt 1 lw 4 lc rgb "black" title 'Ground Truth' set size 0.5,0.5 set origin 0.5,0.5 set xrange [0:0.8] set key off set title '' set lmargin 4 set bmargin 3 set rmargin 0 set tmargin 0 set xtics nomirror set ytics nomirror plot x with lines lt 1 lw 4 lc rgb "red" title 'Median',\ x with lines lw 4 lc rgb "blue" title '$ F,F^{-1}$',\ x with lines lw 4 lc rgb "magenta" title '$ F,\Gamma^\mathcal{P}$',\ x with lines lw 4 lc rgb "orange" title '$\Lambda_\text{MI}$',\ x with lines lt 1 lw 4 lc rgb "green" title 'KNN',\ x with lines lt 1 lw 4 lc rgb "black" title 'Ground Truth' 
+4
source share
1 answer

This is an ugly problem. I have never used the epslatex terminal much - this can cause additional complications, as the documentation states that

"When using the Tex terminal ... where formatting information is embedded in the string, gnuplot can only evaluate the correct width for positioning the string"

You are right that gnuplot does not seem to want to make a key that is wider than the plot - too bad that you cannot explicitly specify the width, as you could with rectangle . It is easy enough to work. The trick is to make your plots (without keys) normal, and then make the final “null” plot, which is as large as you need to match the labels:

 set term ... set output ... #Let the magic begin! set multiplot unset key #<plot 1> #... #</plot 1> #<plot 2> #... #</plot 2> #<plot 3> #... #</plot 3> #<plot 4> #... #</plot 4> #<null> #here we need to unset everything that was set previously unset origin unset border unset tics unset label unset arrow unset title unset object #Now set the size of this plot to something BIG set size 2,2 #however big you need it #example key settings set key box set key horizontal reverse samplen 1 width -4 maxrows 1 maxcols 12 set key at screen 0.5,screen 0.15 center top #We need to set an explicit xrange. Anything will work really. set xrange [-1:1] set yrange [-1:1] plot NaN w title 'title 1',\ NaN w title 'title 2',\ NaN w title 'title 3',\ NaN w title 'title 4' #etc. #</null> unset multiplot #<--- Necessary for some terminals, but not postscript I don't think. 
+3
source

Source: https://habr.com/ru/post/1443477/


All Articles