Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to set the position of a label relative to the key in gnuplot?

The nature of my plot is such that absolute labels don't really work; I can't restrict the range in y, so wondered if there was a way to either include my label text inside the key or have it placed relative to the key (i.e. below)

set term png enhanced size 1024,768
set title "{/=15 1D My title}\n - by me"
set xlabel "x"
set ylabel "y"
set label "V_0 = 10\n E = 1" #this is the bit I want to reposition
set out 'trial.png'
set xrange [-2.5:2.5]
set arrow from -2,-2000 to -2,2000 nohead size screen 0.025,30,45 ls 1
set arrow from 2,-2000 to 2,2000 nohead size screen 0.025,30,45 ls 1
plot 'data.dat'

PS: also, is there a better way to get my vertical lines at x = -2 and x = 2? The arrows solution is again not ideal since my y range is often greater or smaller than 2000.

like image 985
Makkasu Avatar asked Jul 19 '13 10:07

Makkasu


1 Answers

In gnuplot you can use different coordinate systems to set arrows, labels, key and objects. The coordinates may be specified as

  • first: value on the left and bottom axes.
  • second: value on the right and top axes.
  • graph: relative to the area within the axes, 0,0 is bottom left and 1,1 is top right.
  • screen: relative to the entire canvas.
  • character: depends on the chosen font size.

With this, you can set your arrows in the following way:

set arrow from first -2,graph 0 to first -2,graph 1 nohead ls 1
set arrow from first 2,graph 0 to first 2,graph 1 nohead ls 1

You don't need to set a size if you don't have an arrow head.

Although I did not fully understand your label question, I'm sure you will solve it with these information about different coordinate types:

set label "V_0 = 10\n E = 1" right at graph 0.9, graph 0.8
like image 165
Christoph Avatar answered Nov 15 '22 08:11

Christoph