我有一个由2个变量组合观察到的9个点组成的数据集,每个变量有3个值,即
x <- c(0,10,100)
y <- c(0,25,30)
z <- matrix(c(1,2,3,4,5,6,7,8,9), nrow = 3, ncol = 3, byrow = TRUE)
通过这些数据,我创建了一个轮廓图
filled.contour(x,y,z)
另外,我从数据被收集的点创建了散点图
A <- matrix(c(0,0,0,10,10,10,100,100,100), nrow = 3, ncol = 3) #As x
B <- matrix(c(0,0,0,25,25,25,30,30,30), nrow = 3, ncol = 3, byrow = TRUE) #As y
plot(A,B)
但是,当我尝试将它们组合在一起时,它并不能很好地工作。有人可以帮帮我吗?如何在散点图上正确放置散点图?
x <- c(0,10,100)
y <- c(0,25,30)
z <- matrix(c(1,2,3,4,5,6,7,8,9), nrow = 3, ncol = 3, byrow = TRUE)
A <- matrix(c(0,0,0,10,10,10,100,100,100), nrow = 3, ncol = 3) #As x
B <- matrix(c(0,0,0,25,25,25,30,30,30), nrow = 3, ncol = 3, byrow = TRUE) #As y
filled.contour(x,y,z)
points(A,B)
答案 0 :(得分:0)
由@Heikki撰写,我做了一些修改:
x <- c(0,10,100)
y <- c(0,25,30)
z <- matrix(c(1,2,3,4,5,6,7,8,9), nrow = 3, ncol = 3, byrow = TRUE)
A <- matrix(c(0,0,0,10,10,10,100,100,100), nrow = 3, ncol = 3) #As x
B <- matrix(c(0,0,0,25,25,25,30,30,30), nrow = 3, ncol = 3, byrow = TRUE) #As y
filled.contour(x,y,z,#
plot.axes = { axis(1); axis(2); points(A,B)}) #<- New