r-RStudio中的par()和plot()错误


par(mfrow = c(2,1))
plot(pressure$pressure~pressure$temperature)
curve((0.168 + 0.007*x)^(20/3), from = 0, to = 400, add = TRUE)
plot(pressure$pressure^(3/20)~pressure$temperature)
abline(0.168,0.007)

上面是代码。它们将在R中正常运行,但在RStudio中报告错误。我尝试重新安装最新的RStudio,但错误仍然存在。以下是RStudio:中的错误

> par(mfrow = c(2,1))
> plot(pressure$pressure~pressure$temperature)
Error in plot.new() : figure margins too large
> curve((0.168 + 0.007*x)^(20/3), from = 0, to = 400, add = TRUE)
Error in plot.xy(xy.coords(x, y), type = type, ...) : 
invalid graphics state
> plot(pressure$pressure^(3/20)~pressure$temperature)
Error in plot.new() : figure margins too large
> abline(0.168,0.007)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : 
invalid graphics state

以下是我的课程信息:

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Traditional)_Taiwan.950 
[2] LC_CTYPE=Chinese (Traditional)_Taiwan.950   
[3] LC_MONETARY=Chinese (Traditional)_Taiwan.950
[4] LC_NUMERIC=C                                
[5] LC_TIME=Chinese (Traditional)_Taiwan.950    
system code page: 65001
attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     
loaded via a namespace (and not attached):
[1] compiler_4.1.2 tools_4.1.2

在论坛上搜索后,我尝试了以下内容:

> par("mar")
[1] 5.1 4.1 4.1 2.1
> par(mar=c(1,1,1,1))
> par(mfrow = c(2,1))
> plot(pressure$pressure~pressure$temperature)
> curve((0.168 + 0.007*x)^(20/3), from = 0, to = 400, add = TRUE)
> plot(pressure$pressure^(3/20)~pressure$temperature)
> abline(0.168,0.007)

它将运行并生成一个不符合要求的情节(就缩放级别而言,它看起来有点奇怪(:1

作为比较,以下是具有相同代码的R的曲线图:2

有人可以帮助RStudio制作与R相同的情节吗?谢谢

我将设置中的系统比例级别(我使用的是Windows 10(从150%更改为100%。然后错误就消失了。谢谢大家!

最新更新