|
From: Jonathan T. <jt...@as...> - 2014-06-18 23:10:27
|
Philipp K. Janert wrote:
> 3) Key position and offset
> A very similar situation arises with the positioning
> of the key. Frequently, I am happy with the automatic
> positioning, but would like to adjust it slightly.
>
> I can see two solutions for that: one is that
> show key
> would display the actual position of the margin (so
> that this position, when given to "set key at ..."
> would reproduce the previous plot),
Ethan A Merritt <sf...@us...> replied:
: See above. These values can be retrieved from the GPVAL
: variables.
> What variables hold the key position? When I
> do "show variables all", nothing seems appropriate.
: I meant that you can position the key box relative to the plot
: border by using, e.g.
:
: set key top right at graph 0.98, graph 0.98
I've had the same problem as Philipp. It usually strikes when I'm
using the postscript terminal, where gnuplot doesn't know the actual
width of the plot key. I end up doing a fair bit of trial and error
to determine either a "width" adjustment to, or an absolute position for,
the plot key.
An example might make this clearer: Consider the following two gnuplot
scripts (which differ only in their "set key" lines & the names of their
output files):
--- BEGIN #1
set term postscript eps enhanced color solid 14
set output 'key-demo.eps'
set key top left Left reverse samplen 2.5 spacing 1.333
set xrange [0:10]
set yrange [-1:1]
plot (-sin(x)) title "10^6 {/Symbol \264 D} F_{/Symbol f} via Fourier series" \
with lines linetype 1 linewidth 3.0 linecolor rgb "#00A000", \
(-cos(x)) title "10^6 {/Symbol \264 D} F_t" \
with lines linetype 1 linewidth 3.0 linecolor 3
set output
--- END #1
--- BEGIN #2
set term postscript eps enhanced color solid 14
set output 'key-demo2.eps'
# try to mimic the positioning of
# set key top left Left reverse samplen 2.5 spacing 1.333
set key at graph 0.45, graph 0.975 Left reverse samplen 2.5 spacing 1.333
set xrange [0:10]
set yrange [-1:1]
plot (-sin(x)) title "10^6 {/Symbol \264 D} F_{/Symbol f} via Fourier series" \
with lines linetype 1 linewidth 3.0 linecolor rgb "#00A000", \
(-cos(x)) title "10^6 {/Symbol \264 D} F_t" \
with lines linetype 1 linewidth 3.0 linecolor 3
set output
--- END #2
These produce approximately the same output... but I had to find the
numbers 0.45 and 0.975 in the second script by trial and error. Moreover,
the 0.45 must be changed (found by a new round of trial-and-error) if
I change label font, size, text length.
You can see this if you try deleting the text "via Fourier series" from
the label string. The automatically-placed label is still in the same
place, but to get that place manually requires changing that 0.45 to
something more like 0.20 (again determined by trial and error).
What I (and I think also Philipp K. Janert) would like is a way to find
those numbers 0.45 and 0.975 without trial and error, preferably in a
way which doesn't require redoing if I change the label font, size, or
text length.
ciao,
--
-- "Jonathan Thornburg [remove -animal to reply]" <jt...@as...>
Dept of Astronomy & IUCSS, Indiana University, Bloomington, Indiana, USA
currently on the west coast of Canada
"There was of course no way of knowing whether you were being watched
at any given moment. How often, or on what system, the Thought Police
plugged in on any individual wire was guesswork. It was even conceivable
that they watched everybody all the time." -- George Orwell, "1984"
|