R语言绘图生成word时报错:figure margins too large

```{r}
#例.创建了四幅图形并将其排布在两行两列中
attach(mtcars) 
opar <- par(no.readonly=TRUE) 
par(mfrow=c(2,2))
plot(wt,mpg, main="Scatterplot of wt vs. mpg") 
plot(wt,disp, main="Scatterplot of wt vs. disp") 
hist(wt, main="Histogram of wt") 
boxplot(wt, main="Boxplot of wt") 
par(opar) 
detach(mtcars)
#例.依三行一列排布三幅图形
attach(mtcars) 
opar <- par(no.readonly=TRUE) 
par(mfrow=c(3,1)) 
hist(wt) 
hist(mpg) 
hist(disp) 
par(opar) 
detach(mtcars)
#例.一幅图被置于第1行,另两幅图则被置于第2行
attach(mtcars) 
layout(matrix(c(1,1,2,3), 2, 2, byrow = TRUE)) 
hist(wt) 
hist(mpg) 
hist(disp) 
detach(mtcars)
#例.再次将一幅图形置于第1行,两幅图形置于第2行。但第1行中图形的高度是第2行中图形高度的二分之一。除此之外,右下角图形的宽度是左下角图形宽度的三分之一。
attach(mtcars) 
layout(matrix(c(1, 1, 2, 3), 2, 2, byrow = TRUE), 
 widths=c(3, 1), heights=c(1, 2)) 
hist(wt) 
hist(mpg) 
hist(disp) 
detach(mtcars)
##图形布局的精细控制
#设置散点图
opar <- par(no.readonly=TRUE) 
par(fig=c(0, 0.8, 0, 0.8)) 
plot(mtcars$wt, mtcars$mpg, 
 xlab="Miles Per Gallon", 
 ylab="Car Weight")
#在上方添加箱线图
par(fig=c(0, 0.8, 0.55, 1), new=TRUE) 
boxplot(mtcars$wt, horizontal=TRUE, axes=FALSE)
#在右侧添加箱线图
par(fig=c(0.65, 1, 0, 0.8), new=TRUE) 
boxplot(mtcars$mpg, axes=FALSE)

mtext("Enhanced Scatterplot", side=3, outer=TRUE, line=-3) 
par(opar) 
```

是书上的内容,直接运行是可以的,但是Knit生成word就报错了,具体报错如下:

尝试了一下拉大窗口但是也没有用,不知道是什么原因导致的,望指教。谢谢大佬~~

请参考这篇博客使用的解决方案:https://blog.csdn.net/suiming47/article/details/103252166

绘图区不够大,那直接搞张大尺寸的jpg吧,生成jpg时把尺寸定义得足够大就解决问题了。

您好,我是问答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632