Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #896

Re: inlays positioned in graph coordinates?

From Harold <dadapapa@googlemail.com>
Newsgroups comp.graphics.apps.gnuplot
Subject Re: inlays positioned in graph coordinates?
Date 2012-02-02 09:36 -0800
Organization http://groups.google.com
Message-ID <6836f1d9-8d1b-4d12-be1e-e3efdac5c88d@k6g2000vbz.googlegroups.com> (permalink)
References <4ba27ddf-023f-40d4-8880-11fb6df6b8c0@t30g2000vbx.googlegroups.com> <jf4g6q$iid$1@dont-email.me>

Show all headers | View raw


Thanks Ethan,

On Jan 17, 7:55 pm, sfeam <sf...@users.sourceforge.net> wrote:
> Harold wrote:
> > What I would like to do -- if it were possible -- is to set the origin
> > of the inlays in graph coordinates (of the bigger graph), such that I
> > can read them out of the data at processing time. For example, if my
> > data happens to cover the range [-10;100][0;10], I would like to
> > command gnuplot to set the inlay, say at 10,5 (in graph coordinates).
>
> After your first plot, the layout on the page can be reconstructed
> from the internal variables GPVAL_*
> You can inspect these by saying
>     show var GPVAL
>
> axis coords -> graph coords
> ===========================
> The fractional x coordinate relative to the plot borders (graph
> coordinat) of a point with an x-axis coordinate 10 (your example),
> would be
> X_GRAPH = (10. - GPVAL_X_MIN) / (GPVAL_X_MAX - GPVAL_X_MIN)
>
> graph coords -> screen coords
> =============================
> The screen coordinates of the plot borders are also given, so we can
> further convert this to a raw screen coordinate
> X_RAW_SCREEN = GPVAL_TERM_XMIN
>              + (X_GRAPH) * (GPVAL_TERM_XMAX - GPVAL_TERM_XMIN)
>
> The final piece is to convert this raw screen coordinate into a
> fractional screen coordinate.  Unfortunately there is not a GPVAL_*
> variable holding the raw screen size (that's an oversight that we
> should fix!).  You have to take this directly from the requested
> terminal size.  E.g. if you do "set term png size 700,500" then the
> raw screen size on x is 700.   So the final step is
> X_RAW_SCREEN_SIZE =  <something-you-must-provide>
> X_SCREEN = X_RAW_SCREEN / X_RAW_SCREEN_SIZE

This is were I ran into a problem when following your recipe: I use
set terminal postscript eps size 4,3
since this seemed close to the default size, such that the default
font sizes and line widths look neat.

With this setting, however, my values for GPVAL_TERM_XMIN/MAX
are way out of range:
> show var GPVAL
[...]
	GPVAL_TERM_XMIN = 54
	GPVAL_TERM_XMAX = 694
[...]

Hence, the line
X_SCREEN = X_RAW_SCREEN / X_RAW_SCREEN_SIZE
produces values way above 1 (~28 with my numbers).

Is this an issue with the bounding box of the eps driver?

This is an excerpt of the script that I have troubles with:

X_RAW_SCREEN_SIZE = 4
Y_RAW_SCREEN_SIZE = 3

set terminal postscript eps enhanced color solid size
X_RAW_SCREEN_SIZE, Y_RAW_SCREEN_SIZE

L1_min = `head -n1 results/distr_g1e-4_L580633_P7435763.dat | cut -d'
' -f2`
L1_max = `head -n1 results/distr_g1e-4_L580633_P7435763.dat | cut -d'
' -f3`
L1_tot = `head -n1 results/distr_g1e-4_L580633_P7435763.dat | cut -d'
' -f4`
P1_min = `head -n1 results/distr_g1e-4_L580633_P7435763.dat | cut -d'
' -f5`
P1_max = `head -n1 results/distr_g1e-4_L580633_P7435763.dat | cut -d'
' -f6`
P1_tot = `head -n1 results/distr_g1e-4_L580633_P7435763.dat | cut -d'
' -f7`

res    = `head -n1 results/distr_g1e-4_L580633_P7435763.dat | cut -d'
' -f8`

P_min = P5_tot-2e5
P_max = P1_tot+5e4
L_min = L1_tot-2e5
L_max = L5_tot+5e4

set multiplot

set size square
set view map
set palette gray
set xlabel "L"
set ylabel "P"
set xtics 2e+5

set arrow 10 from L1_tot,P1_tot to L5_tot,P5_tot lt -1 lw 2
set arrow 1 from L1_tot,P1_tot to L1_min,P1_min nohead lt 0 lw 3

plot [L_min:L_max][P_min:P_max] -1 t "{/Symbol g} = 10^{`echo $ENERG_G|
cut -de -f2`}" w d lt 0

unset arrow 10
unset arrow 1

unset xlabel
unset ylabel
unset tics
unset colorbox
unset key

# show var GPVAL

X_GRAPH = (L1_min-L_min)/(L_max-L_min)
Y_GRAPH = (P1_min-P_min)/(P_max-P_min)
X_RAW_SCREEN = GPVAL_TERM_XMIN + (X_GRAPH)*(GPVAL_TERM_XMAX-
GPVAL_TERM_XMIN)
Y_RAW_SCREEN = GPVAL_TERM_YMIN + (Y_GRAPH)*(GPVAL_TERM_YMAX-
GPVAL_TERM_YMIN)
X_SCREEN = X_RAW_SCREEN / X_RAW_SCREEN_SIZE
Y_SCREEN = Y_RAW_SCREEN / Y_RAW_SCREEN_SIZE

set origin X_SCREEN, Y_SCREEN
set size .2, .2
clear
splot "results/distr_g1e-4_L580633_P7435763.dat" matrix u (($1*res
+L1_min)):(($2*res+P1_min)):3 w pm3d

unset multiplot


Thanks for your help!

harold.

Back to comp.graphics.apps.gnuplot | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

inlays positioned in graph coordinates? Harold <dadapapa@googlemail.com> - 2012-01-17 06:09 -0800
  Re: inlays positioned in graph coordinates? sfeam <sfeam@users.sourceforge.net> - 2012-01-17 10:55 -0800
    Re: inlays positioned in graph coordinates? Harold <dadapapa@googlemail.com> - 2012-01-19 04:28 -0800
    Re: inlays positioned in graph coordinates? Harold <dadapapa@googlemail.com> - 2012-02-02 09:36 -0800
      Re: inlays positioned in graph coordinates? sfeam <sfeam@users.sourceforge.net> - 2012-02-02 22:05 -0800
        Re: inlays positioned in graph coordinates? mcirri@gmail.com - 2012-08-09 08:27 -0700

csiph-web