使用汽车包装中的散点图并排绘制 [英] Side by side plots using scatterplot from car package

查看:44
本文介绍了使用汽车包装中的散点图并排绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有某种原因不能并排放置两个散点图(来自汽车包装)?

Is there some reason you cannot lay two scatterplot (from car package) figures 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 produces both images, but not as one image side by side.

推荐答案

scatterplot 函数会覆盖您的 par() 配置,因为它会在内部调用 布局() 函数显示散点图和边际箱线图.

The scatterplot function overrides your par() configuration, as it calls internally the layout() function to display the scatterplot along with the marginal boxplots.

该函数的创建者 John Fox 已经回答了这个问题.您可以在 R-help 邮件列表中看到 他的回答.

This question was already answered by John Fox, the creator of that function. You can see his answer at the R-help mailing list.

或者,如果你不信任他,你可以查看源代码并搜索layout.您会发现 if - else if - else if - else 语句,其中 layout() 函数在所有情况下都被调用.

Or, if you do not trust him, you can just have a look at the source code and search for layout. You will find the if - else if - else if - else sentence in which the layout() function is called in all cases.

这篇关于使用汽车包装中的散点图并排绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆