Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This answer is mainly in reply to comments by @java_xof. The reply is too long and includes code so it will not fit in a comment. However, it may help with the original question as well (or at least give a starting place).</p> <p>Here is a function and some code using it (it requires the tcltk and tkrplot packages):</p> <pre><code>library(ggplot2) library(tkrplot) TkPlotLocations &lt;- function(FUN) { require(tkrplot) cl &lt;- substitute(FUN) replot &lt;- function() eval(cl) tt &lt;- tktoplevel() img &lt;- tkrplot(tt, replot, vscale=1.5, hscale=1.5) tkpack(img) tkpack(xfr &lt;- tkframe(tt), side='left') tkpack(yfr &lt;- tkframe(tt), side='left') xndc &lt;- tclVar() yndc &lt;- tclVar() xin &lt;- tclVar() yin &lt;- tclVar() tkgrid(tklabel(xfr, text='x ndc'), tklabel(xfr, textvariable=xndc)) tkgrid(tklabel(yfr, text='y ndc'), tklabel(yfr, textvariable=yndc)) tkgrid(tklabel(xfr, text='x inch'), tklabel(xfr, textvariable=xin)) tkgrid(tklabel(yfr, text='y inch'), tklabel(yfr, textvariable=yin)) iw &lt;- as.numeric(tcl("image","width", tkcget(img, "-image"))) ih &lt;- as.numeric(tcl("image","height",tkcget(img, "-image"))) cc &lt;- function(x,y) { x &lt;- (as.real(x)-1)/iw y &lt;- 1-(as.real(y)-1)/ih c(x,y) } mm &lt;- function(x, y) { xy &lt;- cc(x,y) tclvalue(xndc) &lt;- xy[1] tclvalue(yndc) &lt;- xy[2] tclvalue(xin) &lt;- grconvertX(xy[1], from='ndc', to='inches') tclvalue(yin) &lt;- grconvertY(xy[2], from='ndc', to='inches') } tkbind( img, "&lt;Motion&gt;", mm) invisible() } x &lt;- runif(25) y &lt;- rnorm(25, x, 0.25) plot(x,y) par()$pin par()$plt TkPlotLocations(plot(x,y)) qplot(x,y) par()$pin par()$plt TkPlotLocations(print(qplot(x,y))) qplot(x,y) + xlab('Multi\nline\nx\nlabel') par()$pin par()$plt TkPlotLocations(print(qplot(x,y) + xlab('Multi\nline\nx\nlabel'))) </code></pre> <p>Defining the above function, then running the following lines will produce 3 plots of the same random data. You can see that the results of <code>par()$pin</code> and <code>par()$plt</code> (and other parameters) are exactly the same for the 3 plots even though the plotting regions differ in the plots.</p> <p>There will also be 3 new windows that have popped up, in the windows you can move the mouse pointer over the graph and at the bottom of the window you will see the current location of the pointer in normalized device coordinates and in inches (both from the bottom left corner of the device region). You can hover the mouse pointer over the corners of the graph (or any other part) to see the values and compare between the 3 graphs.</p> <p>This may be enough to answer at least part of the original question (just not programatically, which would be more useful). The functon can be modified to print out other measurements as well. I may expand this and include it in a package in the future if others would be interested.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload