Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: sfeam Newsgroups: comp.graphics.apps.gnuplot Subject: Re: inlays positioned in graph coordinates? Followup-To: comp.graphics.apps.gnuplot Date: Thu, 02 Feb 2012 22:05:52 -0800 Organization: gnuplot development team Lines: 154 Message-ID: References: <4ba27ddf-023f-40d4-8880-11fb6df6b8c0@t30g2000vbx.googlegroups.com> <6836f1d9-8d1b-4d12-be1e-e3efdac5c88d@k6g2000vbz.googlegroups.com> Reply-To: sfeam@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Date: Fri, 3 Feb 2012 06:05:54 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="3mhAfh4CeAIeL3OKnPexDA"; logging-data="29283"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/MgBlnezyEKu81Jxr/3Pos" User-Agent: KNode/4.4.9 Cancel-Lock: sha1:6kRvdATRB1yERIsFTQFB9iCSYgM= Xref: x330-a1.tempe.blueboxinc.net comp.graphics.apps.gnuplot:899 Harold wrote: > Thanks Ethan, > > On Jan 17, 7:55 pm, sfeam 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 = >> 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? Not exactly. It's a mis-match of units. The "set term post eps size 4,3" specifies x and y in inches (by default). But the internal terminal coordinates are different from that. The missing variable X_RAW_SCREEN_SIZE would in this case be 5760, not that there's any easy way for you to know that. As a result of this thread, the CVS version of gnuplot now exports this value as GPVAL_TERM_XSIZE. This will be true in the released version of 4.6 as well. For now what you need to know is that the requested eps terminal size in inches must be multiplied by 1440 to get the size in internal coordinates. Ethan > 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.