1

I have some shaded area in a plot and I'd like to label that shaded area with a small rectangle of the same hue as the shading in the plot.

I'm using gnuplot - my shading in the plot is achieved with

plot  'XXXX.dat' u 1:($2+$3):($2-$3) w filledcurve ls 999 fs solid 0.2 notitle,\

and I'd like to label the shading area in the key with a small rectangle of the same hue.

Is it possible? I'm also happy to set it manually via

set object rectangle from x1,y1 to x2,y2 fc rgb "blue"

but in this way I've only managed to sample colours from the standard gnu plot palette and not the hue I've set for the shading via fs solid 0.2.

Thanks!

CAF
  • 329
  • 3
  • 14

2 Answers2

1

I'm not sure if I understand your problem. If you want the filled area in your key you have to define a keyentry via title but you are using notitle.

Code:

set key out
plot '+' u 1:($1**2) w filledcurves ls 999 fs solid 0.2 title "filled area"

Result:

enter image description here

theozh
  • 22,244
  • 5
  • 28
  • 72
1

If theozh's answer does not apply, e.g. if you want a key entry with a color that is not the entire plot, then current gnuplot (version 5.2.6 or newer) offers a special plot component keyentry that produces a title and sample for any plot style without actually plotting anything. Example:

set key title "Key made with explicit \n{/:Italic keyentry} elements"
plot keyentry with points pt '¶' title "points", \
     keyentry with lp title "lp", \
     keyentry with yerrorbars title "yerrorbars", \
     keyentry with xyerrorlines title "xyerrorlines", \
     keyentry with circles fs solid fc "dark-red" title "circles", \
     keyentry with ellipses title "ellipses", \
sin(x)/x lc "grey" dt '.-' lw 3 title "normal plot", \
     keyentry with boxerrorbars title "boxerrorbars", \
     keyentry with boxplot fs pattern 1 title "boxplot", \
     keyentry with labels point pt 4 title "labels", \
     keyentry with vectors title "vectors"

enter image description here

Ethan
  • 13,715
  • 2
  • 12
  • 21