How to change the key box border color in gnuplot?

Viewed 23

I have this gnuplot script:

set title font "Monospaced,13" 'Add at random spot'
set grid
set key height 2 box left top

set style line 1 \
    linecolor rgb '#ff8844' \
    linetype 1 linewidth 3 \
    pointtype 5 pointsize 1.5

set style line 2 \
    linecolor rgb '#22ff22' \
    linetype 1 linewidth 3 \
    pointtype 5 pointsize 1.5

set xlabel 'Size'
set ylabel 'Microseconds'
set xrange [0:1000000]

plot 'SO.dat' index 1 with linespoints linestyle 1 title "Indexed list", \
     ''       index 3 with linespoints linestyle 2 title "Tree list

set terminal png size 650,350 enhanced font "Monospaced,13"
set output 'SO.png'
replot
exit

(data is here),

... and it produces:

gnuplot PNG

What I wish to achieve is to tweak the color of the legend box. How could I do it?

1 Answers

Please read help key:

Syntax: 

      set key {on|off} {default}
            {{inside | outside | fixed} | {lmargin | rmargin | tmargin | bmargin}
              | {at <position>}}
            {left | right | center} {top | bottom | center}
            {vertical | horizontal} {Left | Right}
            {{no}enhanced}
            {{no}opaque}
            {{no}reverse} {{no}invert}
            {samplen <sample_length>} {spacing <line_spacing>}
            {width <width_increment>} {height <height_increment>}
            {{no}autotitle {columnheader}}
            {title {"<text>"} {{no}enhanced} {center | left | right}}
            {font "<face>,<size>"} {textcolor <colorspec>}
            {{no}box {linestyle <style> | linetype <type> | linewidth <width>}}
            {maxcols {<max no. of columns> | auto}}
            {maxrows {<max no. of rows> | auto}}
      unset key
      show key

From this, it looks like you have to go via set style line 1 lc "red" and then set set key box ls 1. Although, it is not explicitly mentioned, apparently you can simply do set key box lc "red".

Script:

### colored border of box for key/legend
reset session

set key opaque box lc "red" lw 2 font ",14"

plot sin(x), cos(x)
### end of script

Result:

enter image description here

Related