1

I would like get something like this:

Rectangle outside graph:

enter image description here

Could I get that with set object <number> rect ? Or is this only to draw rectangles inside graph?

theozh
  • 22,244
  • 5
  • 28
  • 72
jfernandz
  • 185
  • 1
  • 10

2 Answers2

4

you can use the screen coordinates (which refer to the entire window) like so:

set object 1 rect from screen 0.0, screen 0.9 to screen 0.1, screen 1.0

this would create a rectangle in the top left 10% of the plotting window

ewcz
  • 12,819
  • 1
  • 25
  • 47
1

As suggested in @ewcz's answer, you can use screen coordinates for drawing objects (partly) outside the graph area . However, if you check help object and you will find the option noclip at least since gnuplot 4.6.5. (default is clip).

With this you can draw objects outside the graph using, e.g. graph, first, second, etc. coordinates as well (check help coordinates), especially in case you want to adjust the size of your rectangle to graph or x/y-coordinates.

Script:

### draw rectangle outside graph area
reset session

set xrange [0:20]
set yrange [0:10]

set xlabel "x-axis"
set ylabel "y-axis"
set origin 0.1, 0.1
set size   0.8, 0.8

set obj 1 rect noclip from graph -0.1, 0.9 to graph 0.1, 1.1 
set obj 1 fs empty border rgb "red" lw 2 dt 4

set obj 2 rect noclip from first -2,-2 to first 7,3
set obj 2 fs empty border rgb "green" lw 2 dt 1

set obj 3 rect noclip from screen 0.6,0.6 to screen 1,1
set obj 3 fs empty border rgb "blue" lw 2 dt 3

plot x
### end of script

Result:

enter image description here

theozh
  • 22,244
  • 5
  • 28
  • 72