posit-dev / positron

Positron, a next-generation data science IDE
Other
1.21k stars 32 forks source link

Cannot arrange multiple R plots in same plotting space with par #3562

Open timtmok opened 2 weeks ago

timtmok commented 2 weeks ago

Positron Version:

Positron Version: 2024.06.0 (Universal) build 770 Code - OSS Version: 1.90.0 Commit: 5d79ea68dceb5b734475af851b64cb3c0a323285 Date: 2024-06-14T05:53:04.122Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.4.0

R 4.4.0

Steps to reproduce the issue:

  1. Run reprex

Reprex:

par(mfrow=c(3,1))

hist(iris$Petal.Width [iris$Species == "setosa"],
     xlim = c(0,3),
     breaks = 9,
     main = "Petal Width for Setosa",
     xlab = "",
     col = "red")

hist(iris$Petal.Width [iris$Species == "virginica"],
     xlim = c(0,3),
     breaks = 9,
     main = "Petal Width for Virginica",
     xlab = "",
     col = "green")

hist(iris$Petal.Width [iris$Species == "versicolor"],
     xlim = c(0,3),
     breaks = 9,
     main = "Petal Width for Versicolor",
     xlab = "",
     col = "blue")

par(mfrow=c(1,1)) # reset layout

This usually happens in RStudio if the plots pane is too small. Enlarging the plots view in Positron doesn't seem to help. Using par(mfrow=c(1,3)) does work if the plots view is wide enough but doesn't always update to show the last plot. It does fail if setting a custom plot size of 100x100. A larger custom plot size still has an error with the reprex.

What did you expect to happen?

All three plots render in the same plotting space like this: image

Were there any error messages in the output or Developer Tools console?

Error in `plot.new()`:
! figure margins too large
Hide Traceback
    ▆
 1. ├─graphics::hist(...)
 2. └─graphics::hist.default(...)
 3.   ├─base::plot(...)
 4.   └─graphics:::plot.histogram(...)
 5.     └─graphics::plot.new()
jmcphers commented 1 week ago

Reported today by a beta user: https://github.com/posit-dev/positron-beta/discussions/222