I would like to increase the key symbol for filledcurves
plot style. I can control the length using set key samplen <value>
but not the height for it. I can reach the result wanted but the used way is cumbersome and depends both size plot and font used.
I used datafile.dat
file
1 1270 834
2 1112 900
3 794 982
4 656 710
and this code
reset
set encoding utf8
set terminal pngcairo size 500,500 font "Segoe UI,10"
set output "boxes.png"
set key title "{/:Bold Auto key}" Left reverse samplen 2
set tics out nomirror
set xrange [0:5]
unset xtics
set palette defined (\
1 "dark-violet",\
2 "#009e73",\
3 "#56b4e9",\
4 "#e69f00"\
)
unset colorbox
set errorbars small
set macros
style = "solid 0.5 border lt -1"
set style fill @style
# -----------------------------------------------
posX = 0.55 # x position (at screen)
posY = 0.9 # y position (at screen)
shiftY = 0.035 # shift in y direction (from up to down)
sizeX = 0.020 # box width
sizeY = 0.012 # box height
set label "{/:Bold Manual key}" at screen posX, posY left offset 0,1.2
set obj rect center screen posX,posY-0*shiftY size screen 2*sizeX,2*sizeY fc ls 1 fs @style
set obj rect center screen posX,posY-1*shiftY size screen 2*sizeX,2*sizeY fc ls 2 fs @style
set obj rect center screen posX,posY-2*shiftY size screen 2*sizeX,2*sizeY fc ls 3 fs @style
set obj rect center screen posX,posY-3*shiftY size screen 2*sizeX,2*sizeY fc ls 4 fs @style
set arrow from screen posX-sizeX, posY-4*shiftY to screen posX+sizeX, posY-4*shiftY lw 3 nohead
set label "Method 1" at screen posX, posY-0*shiftY left offset 2,0.05
set label "Method 2" at screen posX, posY-1*shiftY left offset 2,0.05
set label "Method 3" at screen posX, posY-2*shiftY left offset 2,0.05
set label "Method 4" at screen posX, posY-3*shiftY left offset 2,0.05
set label "Reference" at screen posX, posY-4*shiftY left offset 2,0.05
# -----------------------------------------------
plot \
keyentry w filledcurves ls 1 title "Method 1",\
keyentry w filledcurves ls 2 title "Method 2",\
keyentry w filledcurves ls 3 title "Method 3",\
keyentry w filledcurves ls 4 title "Method 4",\
"datafile.dat" u 1:2:0 w boxes lc palette notitle,\
"" u 1:3:(0.5) w xerrorbars ls -1 pt -1 lw 3 title "Reference"
to do this plot
Is there another way to do this?
Is there another way? Yes, but it's a bit ugly. The height of the key sample is determined by the font size used for the key titles. You can abuse this by setting the key to use a large font and then overriding it for the actual text of each plot title.
The following example sets the key font to 20 point and uses enhanced text mode to reduce the size back to 10 point when composing the title text. You can ignore the complicated using
and every
bits, it's just a way of generating some fake data to plot.
set term pngcairo size 500,500 font "ArnoPro,10"
set output "boxes.png"
$DATA << EOD
5
2
4
3
1
EOD
set yrange [0:6]
set style fill solid 1.0 border lc "black"
set boxwidth 0.3
set key font "ArnoPro,20" enhanced
plot for [i=1:5] $DATA every ::(i-1)::(i-1) using (i):(column(1)) with boxes \
title sprintf("{/ArnoPro=10 Method %d}", i)