1

At present there are two problems:

Problem 1: This problem has been solevd thanks to @Humpelstielzchen, it's because the "noRStudioGD = TRUE" issue.

I looked at this post, and tried Shane's answer, which is:

# the plot with width=5
dev.new(width=5, height=4)
plot(1:20)

Then I tried to change the width from 5 to 10, to see if there is some different:

# the plot with width=10
dev.new(width=10, height=4)
plot(1:20)

but it seems no change of the picture's size at all (see here). Why does this happen?

Problem 2: I changed the units = (cm or inch), but the Plot Window seems unchanged. More strangely, the width of these two windows is 23.2 cm, the height is 10.5 cm: these vaules are neither 10 cm or 10 inch for width, and 4 cm or 4 inch for height.

# units = "cm"
dev.new(width=10, height=4, noRStudioGD = TRUE, units = "cm")
plot(1:20, main = "units = cm")

# units = "inch"
dev.new(width=10, height=4, noRStudioGD = TRUE, units = "inch")
plot(1:20, main = "units = inch")
T X
  • 505
  • 1
  • 9
  • 19

1 Answers1

1

You have to do


dev.new(width=10, height=4, noRStudioGD = TRUE, units = "cm")
plot(1:20)

They apparently changed the behaviour of dev.new() in RStudio some time ago.

There is also something about it in the description: ? dev.new

Humpelstielzchen
  • 6,126
  • 3
  • 14
  • 34
  • Now the two plots have different width. But the `"width=10"` plot seems not the width of 10 inch: I used a ruler to measure it, it's 23 cm width. It should be 25.4 cm width of the plot window. – T X Apr 10 '19 at 07:24
  • that's because the default unit is inches. Try my update. – Humpelstielzchen Apr 10 '19 at 07:27
  • I checked the "units = " option, but a problem occurred (see **Problem 2** in my updated question) – T X Apr 10 '19 at 08:08
  • that's a good question. Others had the same problem but I didn't find a reason or solution. Have you tried saving the plot to a file and checking measurements there? – Humpelstielzchen Apr 10 '19 at 11:42
  • I saved them to "png" file, and their width are all 15.5 cm, height are 6.2 cm. This time, the aspect ratio (15.5:6.2 = 2.5) is strictly the same as the original set (10:4 = 2.5). This is better than the plot directly shown in RStudio (23.2:10.5 = 2.21). Although the "absolue" width or height still doesn't meet with the code. – T X Apr 10 '19 at 13:53