[R] Plotting two graphs on the same figure

David Winsemius dwinsemius at comcast.net
Tue Jan 15 02:01:36 CET 2013


On Jan 14, 2013, at 3:32 PM, Lily Arias Chauca wrote:

> 
> I want to add a line that represents the relationship between x and y to a strip chart, I've tried the following functions:
> par(new=TRUE)
> points(x,y)
> lines(x,y)
> 
> but nothing works, I get the strip chart but line doesn't show up. Here is my function:
> 
> stripchart(hydfin$exp ~ hydfin$alt, vert = TRUE, pch = 1, method = "jitter", jit = 0.05, xlab = "Elevation", ylab = expression(paste(delta^{2}, "H")))
> points(1:3, hydfin.M, pch = 16, cex = 1.5)
> arrows(1:3, hydfin.M, 1:3, hydfin.M + hydfin.se, lwd = 1.5, angle = 90, length = 0.1)
> arrows(1:3, hydfin.M, 1:3, hydfin.M - hydfin.se, lwd = 1.5, angle = 90, length = 0.1)
> par(new=TRUE)
> lines(hydfin$exp, hydfin$alt,type="l",col="red")

You are probably not plotting to the right coordinates. (You are reversing the x and y roles.)  Please include the output of dput(head(hydfin))


-- 
David Winsemius
Alameda, CA, USA



More information about the R-help mailing list