我想比较具有相同 x 和 y 变量的两个数据集。然而,并非所有 X 变量点都存在于两者上。作为一个玩具示例,这就是我所拥有的:
position.x <- c(1,2,3)
score.x <- c(450,220,330)
x <- data.frame(position,score.x)
position.y <- c(2,3,5)
score.y <- c(333,423,988)
y<- data.frame(position.y,score.y)
par(mfrow = c(2,1))
plot(x, pch = 19)
plot(y, pch = 19)
X 轴不可比较。我发现一些帖子解释了如何使用 facet_wrap
在 ggplot 上执行此操作,但我想使用基本图来执行此操作。
提前谢谢你。
最佳答案
您可以通过xlim
和slim
指定x 和y 轴的范围
position.x <- c(1,2,3)
score.x <- c(450,220,330)
x <- data.frame(position,score.x)
position.y <- c(2,3,5)
score.y <- c(333,423,988)
y<- data.frame(position.y,score.y)
par(mfrow = c(2,1))
plot(x, pch = 19, xlim=c(1,5))
plot(y, pch = 19, xlim=c(1,5))
关于r - Facet_wrap 像使用 R 基础图形的绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29129252/