R中一个图中的多个图:如果只有一列则出错

Multiple plots in one figure in R: Error if only ONE column

我正在尝试使用 R/RStudio 将多个数字合并为一个。在绘制 2 x 2、3 x 5 等时效果很好。除了绘制一列外,它适用于所有组合。如果我尝试使用 an example of the rather renomated help site statmethods.net

绘制一列
# 3 figures arranged in 3 rows and 1 column
attach(mtcars)
par(mfrow=c(3,1))
hist(wt)
hist(mpg)
hist(disp)

我在第二个情节后立即收到消息:

hist(mpg)

Error in plot.new() : figure margins too large

有没有人遇到过同样的问题?

如果绘图 window 对于您要绘制的内容来说太小,RStudio 将抛出该错误。您可以尝试将该图 window 拖动到相对于控制台等更大的位置,或者您可以将您的图直接写入文件,例如使用 pdf()dev.off().