[R] window (x,y) co-ordinates of datapoints
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Oct 9 13:34:35 CEST 2007
On Tue, 9 Oct 2007, Samuel Kemp wrote:
> In the getGraphicsEvent function the (x,y) co-ordinates returned from the
> mouse move are in relation to where the mouse is located within the device
> window (i.e. the lower left corner of the window is '(0,0)', the upper
> right is '(1,1)').
You do realise that is specific to the windows() device? The
getGraphicsEvent() help does not say what happens on the windows() device
if 'rescale != "R"', when the 'window' is not simply related to the device
surface -- so I'll ignore that.
> Is there a way of returning the (x,y) co-ordinates of
> data points plotted where instead of x and y being the actual data points
> they are the coordinates of the device window.
> e.g. below is a simple plot of x,y data
> x <- 1:10
> y <- x*20
> what I actually want to know is where (x,y) is within the device
> Does any-one have any ideas?
Read ?par and the descriptiuon in 'An Introduction to R'. "din", "fin",
"mai", "omi", "pin" and "usr" are relevant.
You have only one figure, no outer margins and linear scales. For your
example on Linux (after resizing) I got
 9.162549 6.407743
 1.0407480 0.8366798 0.8366798 0.4285433
 7.897326 4.530315
which tells me the plot region has corners (0.8366798, 1.0407480) and
 0.64 10.36 12.80 207.20
tells me the user coordinates of those corners. That suffices to do the
> Thanks in advance,
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help