如何在多个图中选择一个要编辑的图?

时间:2015-11-13 12:18:25

标签: r plot scatter-plot

我试图在一张图片中绘制两个图并编辑两个图的x和y轴。但我只能编辑右边的情节。我无法编辑左边的情节。命令如下:

#divide ploting area in one row and two columns:
par(mfrow=c(1,2))
#plot the two graphics already with the same y limits:
plot(Age[Gender=="male"], Height[Gender=="male"], las = 1, main = "Age x Height for Males", xlab = "Age", ylab = "Height", ylim = c(45,85), axes = F)
plot(Age[Gender=="female"], Height[Gender=="female"], las = 1, main = "Age x Height for Females", xlab = "Age", ylab = "Height", ylim = c(45,85), axes = F)
#edit the "x" axis
axis(side=1, at = c(3, 6, 10), labels = c("3", "6", "10"))

这就是我所拥有的:第二幅图形的“x”轴被编辑,我无法回到第一张图。

enter image description here

1 个答案:

答案 0 :(得分:1)

正如user20650所述:在每个绘图命令后调用您的编辑。 在你的情况下:

par(mfrow=c(1,2))
plot(Age[Gender=="male"], Height[Gender=="male"], las = 1, main = "Age x Height for Males", xlab = "Age", ylab = "Height", ylim = c(45,85), axes = F)
axis(side=1, at = c(3, 6, 10), labels = c("3", "6", "10"))
plot(Age[Gender=="female"], Height[Gender=="female"], las = 1, main = "Age x Height for Females", xlab = "Age", ylab = "Height", ylim = c(45,85), axes = F)
axis(side=1, at = c(3, 6, 10), labels = c("3", "6", "10"))
相关问题