简体   繁体   中英

How to select one plot to be edit in multiple plots?

I am trying to plot two plots in only one picture and to edit the x and y axis of both plots. But I can only edit the plot to the right. I cannot edit the plot to the left. Commands are as follows:

#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"))

And this is what I've got: the "x" axis of the second graphic was edited and I cannot go back to the first plot.

在此处输入图片说明

As user20650 stated: call your edits after each plot command. In your case:

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"))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM