BCArg
BCArg

Reputation: 2250

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.

enter image description here

Upvotes: 1

Views: 376

Answers (1)

schosse-sitzer
schosse-sitzer

Reputation: 460

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

Upvotes: 1

Related Questions