[R] hexbin and grid - input data values as coordinates
Adaikalavan Ramasamy
ramasamy at cancer.org.uk
Thu Mar 31 23:46:29 CEST 2005
Dear all,
I am trying to use hexbin and read the very interesting article on grid
( http://www.ci.tuwien.ac.at/Conferences/useR-2004/Keynotes/Murrell.pdf ) and am hoping for some advice from more experienced users of hexbin.
I am trying to visualise a data and fit a straight line trough it. For
example, here is how I would do it in the usual way
# simulate data
x <- rnorm(1000)
y <- 5*x + rnorm(1000, sd=0.5)
plot( x, y, pch="*" )
abline(0, 1, col=2)
And here is my failed attempt at fitting the "abline" on hexbin
library(hexbin); library(grid)
plot( hexbin( x, y ), style = "nested.lattice")
grid.move.to(0.2,0.2)
grid.line.to(0.8,0.8)
I realise that grid.* is taking plotting coordinates on the graph but
how do I tell it to use the coordinates based on the data values ? For
my real data, I would like lines with different slopes and intercepts.
I am using the hexbin version 1.2-0 ( which is the devel version ),
R-2.0.1 and Fedora Core 3.
Many thanks in advance.
Regards, Adai
More information about the R-help
mailing list