[R] r-plot 2nd attempt
Gavin Simpson
gavin.simpson at ucl.ac.uk
Wed May 27 22:35:53 CEST 2009
On Wed, 2009-05-27 at 06:06 -0700, durden10 wrote:
> First of all, thanks a lot for your quick & helpful comments!
>
> I have come down to this:
>
> Win<- c(-0.005276404, 0.081894394, -0.073461539, 0.184371967,
> 0.133189670, -0.006239016, -0.063616699, 0.196754234, 0.402148743,
> 0.104408425,
> 0.036910154, 0.195227863, 0.212743723, 0.280889666, 0.300277802)
> Calgary<- c(5, 8, 11, 3, 7, 4, 7, 1, 3, 6, 3, 2, 8, 0, 1)
>
> data_corr <- data.frame(Win,Calgary)
> plot(data_corr, type = "p", axes=FALSE, col = "blue", lwd = 2)
>
> #y-axis
> axis(2, tcl=0.35,seq(1,11,by=2))
>
> #x-axis
> axis(1, tcl=0.35,seq(-0.1,0.5,by=0.1))
> box()
>
> abline(lm(data_corr[,2]~data_corr[,1]))
>
> It works for the y-axis, but unfortunately, the x-axis is still not working:
> It starts at 0 and end at 0.4, but it should start at -0.1
Why? Your data extend to ~-0.07.
> , as mentioned in
> the code (cf picture) :confused:
> http://www.nabble.com/file/p23742121/Rplots_2.png
You didn't adjust the x-axis limits to tell R that you wanted -0.1 to be
include on the lower end of the axis. R isn't clairvoyant you know!
I've tidied your script and altered it to extend the x-axis a bit so
that -0.1 is included:
Win <- c(-0.005276404, 0.081894394, -0.073461539, 0.184371967,
0.133189670, -0.006239016, -0.063616699, 0.196754234,
0.402148743, 0.104408425, 0.036910154, 0.195227863,
0.212743723, 0.280889666, 0.300277802)
Calgary<- c(5, 8, 11, 3, 7, 4, 7, 1, 3, 6, 3, 2, 8, 0, 1)
data_corr <- data.frame(Win, Calgary)
plot(Calgary ~ Win, data = data_corr, type = "p", axes = FALSE,
col = "blue", lwd = 2, xlim = c(-0.1,0.5))
## ^^^^^^^^^^^^^^^^^^
axis(2, tcl = 0.35, seq(1, 11, by=2))
axis(1, tcl = 0.35, seq(-0.1, 0.5, by=0.1))
box()
abline(lm(Calgary ~ Win, data = data_corr))
HTH
G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list