开发者

stack contour plot in R

开发者 https://www.devze.com 2023-02-11 03:33 出处:网络
I have two different matrices (same x and y axis) which a plot as contour plots contour (x,y,z). I would like to figure out how 开发者_Python百科to stack both matrix into a single plot in R.

I have two different matrices (same x and y axis) which a plot as contour plots contour (x,y,z). I would like to figure out how 开发者_Python百科to stack both matrix into a single plot in R.

I've been trying to use the as.layer function but it doesn't work

heteroplot <- contour(a[,1],t(a[,1]),nlevels=7,heterocov^2,col="green",xlab="ppm",ylab="ppm",bty="n")

homocov <- contour(a[,1],t(a[,1]),nlevels=7,cova^2,col="red",xlab="ppm",ylab="ppm",bty="n")

as.layer(homocov,x.same = TRUE, y.same = TRUE)

thanks!


You can do this, if I've understood correctly, using the add argument to contour(). For example:

x <- -6:16
y <- x
z1 <- outer(x, sqrt(abs(x)), FUN = "/")
z2 <- outer(x, abs(x), FUN = "/")
contour(x, x, z1)
contour(x, x, z2, add = TRUE, col = "red") ## overlay second contour

which gives:

stack contour plot in R

Not sure where the as.layer function comes from...?

0

精彩评论

暂无评论...
验证码 换一张
取 消