Side by side using dispersion diagrams from car packaging

Is there any reason why you cannot lay two scatterplots (from automobile packaging) side by side?

library(car)

str(UN)

par(mfrow=c(1,2))
scatterplot(infant.mortality~gdp,data=UN,
            xlab="GDP per capita",
            ylab="Infant Morality Rate (per 1000 births)",
            main="(a)",
            boxplot=FALSE)
scatterplot(infant.mortality~gdp,data=UN,
            xlab="GDP per capita",
            ylab="Infant Morality Rate (per 1000 births)",
            main="(b)",
            log='xy',
            boxplot=FALSE,id.n=4)
par(mfrow=c(1,1))

The above code creates both images, but not as one image side by side.

+3
source share
1 answer

The function scatterplotoverrides your configuration par()as it internally calls the function layout()to display a scatter chart along with marginal boxes.

This question was answered by John Fox, creator of this feature. You can see his answer on the R-help mailing list .

, , layout. if - else if - else if - else, layout() .

+1

Source: https://habr.com/ru/post/1661750/


All Articles