S.D
S.D

Reputation:

How to change the size of legend-box and size of fonts inside a legend box?

I need to contruct a figure with at least 12 plots in gnuplot epslatex terminal. The problem is when number of plots becomes larger, the size of legend box becomes larger and it gets overlapped with the plots. How can I control the font size inside a legend box and also the size and positioning of the legend box? My gnuplot script is as below. After compilation of script file , the tex file which is produced could not be compiled.Please advise.

Gnuplot script:

reset
set terminal epslatex color colortext size 11cm,7.5cm standalone
set output "obspI=12.tex"

set style data lines
set multiplot
set log


set key samplen 1 left bottom 
set key at 0.02,0.005
set key box lt 1 lc -2 lw 3

set xlabel "$t/N$"
set ylabel '$P_\ell(t)$'

set format y  '$10^{%L}$'
set format x  '$10^{%L}$'

set xr [0.01:1000]
set yr [0.002:1.5] 

plot 'sp_e21_N20I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=20,E=21$' lc 7 lw 2, \
     'sp_e19_N20I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=20,E=19$' lc 1 lw 2, \
     'sp_n_N20I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=20$', \
     'sp_e21_N20I10.dat' u 1:2 w l title '\footnotesize $\ell=10,N=20,E=21$'  lw 2, \
     'sp_e19_N20I10.dat' u 1:2 w l title '\footnotesize $\ell=10,N=20,E=19$'  lw 2, \
     'sp_n_N20I10.dat'   u 1:2 w l title '\footnotesize $\ell=10,N=20$'  lw 2, \
     'sp_e21_N40I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=40,E=21$'  lw 2, \
     'sp_e19_N40I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=40,E=19$'  lw 2, \
     'sp_n_N40I1.dat' u 1:2 w l title '\footnotesize $\ell=1,N=40$', \
     'sp_e21_N40I20.dat' u 1:2 w l title '\footnotesize $\ell=20,N=40,E=21$'  lw 2, \
     'sp_e19_N40I20.dat' u 1:2 w l title '\footnotesize $\ell=20,N=40,E=19$'  lw 2, \
     'sp_n_N40I20.dat'   u 1:2 w l title '\footnotesize $\ell=20,N=40$'  lw 2

unset multiplot
set output

Upvotes: 10

Views: 37443

Answers (1)

mike622867
mike622867

Reputation: 377

The key text size (with or without a box) can be controlled by

set key font ",FONT_SIZE"

(where FONT_SIZE can be 10.5 for example).

For positioning the key box, see here. There are plenty of options; you can position the key outside the main figure using, e.g.,

set key outside

Height and width of the key box can be controlled by "height" and "width", e.g.:

set key width -12

Hope that helped.

Upvotes: 14

Related Questions