0
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)

Above is the code. They will run normally in R, but report errors in RStudio. I have tried reinstall the latest RStudio but the errors persist. Here are the errors in 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

Below is my sessioninfo:

> 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

Upon some search on the forum, I tried the following:

> 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)

It will run and produce a plot that is not as desired (It looks a bit weird in terms of zoom levels): 1

As a comparison, here is the plot from R with the same codes: 2

Anyone could help to let the RStudio produce the same plot as R? Thanks!

user438383
  • 5,716
  • 8
  • 28
  • 43
Hsin
  • 11
  • 2
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Feb 15 '22 at 17:27
  • @MrFlick, thanks for your reply! One line was missing previously and I have added it. The dataset pressure is built-in in R. You should be able to run those codes directly. – Hsin Feb 15 '22 at 17:29
  • Since you solved your own question - please put the solution as an answer and select that so future viewers will know this is a solved problem and can benefit from what you found. – Dan Adams Feb 15 '22 at 17:40

1 Answers1

1

I changed the system scale level in the settings (I'm using Windows 10) from 150% to 100%. Then the errors are gone. Thanks all!

Hsin
  • 11
  • 2