r - Facet_wrap 像使用 R 基础图形的绘图

标签 r plot

我想比较具有相同 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)

enter image description here

X 轴不可比较。我发现一些帖子解释了如何使用 facet_wrap 在 ggplot 上执行此操作,但我想使用基本图来执行此操作。

提前谢谢你。

最佳答案

您可以通过xlimslim 指定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))

enter image description here

关于r - Facet_wrap 像使用 R 基础图形的绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29129252/

相关文章:

r - ggplot2:带有分类轴和叠加点的闪避点

r - 在 ggplot2 中为主题添加一个参数

r - 在 R 中转换 3D 数组中的表格

r - 将因子转换为原始数值

plot - 3D 框(直方图) Gnuplot 与 cairolatex(或 epslatex)

Matlab 查询 : How to align 'title' at the botton of the figure when plotting points

r - 如何在 R Shiny 中将多个绘图下载为zip文件?

使用键重新映射数据库

通过 dplyr group_by 运行列表并每次进行总结和变异

graph - 如何导航 Octave 图?