Gareth Walker
Gareth Walker

Reputation: 213

Gnuplot key: sample and title positions

Is it possible to adjust the relative vertical position of the sample in a key and its title? Running these commands

set terminal pdfcairo
set output 'foo.pdf'
set yrange [-1.2:1.2]
plot sin(x)

produces a plot with a key that looks like this:

Gnuplot key

I'd like the sample in the key to be a bit lower relative to the title in the key (or the title in the key a bit higher relative to the sample in the key).

EDIT: There seem to be other issues with alignment, not just in the key. This is the whole graphic produced by the commands above, using the latest Gnuplot installed by homebrew on OSX 10.10.5 (Gnuplot 5.2.2, cairo 1.14.12). The same thing is evident on OSX 10.11.6. At least some of the labels on the xaxis seem to be shifted a bit to the right of the tic, and labels on the yaxis seem to be shifted down.

enter image description here

Upvotes: 1

Views: 3123

Answers (1)

vaettchen
vaettchen

Reputation: 7659

help set key provides you with all necessary details. In your case, probably

set key left

would already help. But there is also the option to tell gnuplot precisely where you want the key to be placed, using

# This places a key at coordinates x = 6.5 and y = 0.8 in the coordinate system:
set key at 6.5,0.8

Another way, rather than playing around with key positions, is also to adjust the range in a way that comfortable space is left for the key, in your case

plot [-10:+10][-1.1:1.2] sin(x)

might help.

enter image description here

Upvotes: 2

Related Questions