posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.83k stars 91 forks source link

Cannot produce tinyplot (i.e., base R plot with adjusted `par(mar = ...)`) #3667

Open grantmcdermott opened 5 months ago

grantmcdermott commented 5 months ago

Positron Version:

Positron Version: 2024.06.1 (Universal) build 27 Code - OSS Version: 1.90.0 Commit: a893e5b282612ccb2200102957ac38d3c14e5196 Date: 2024-06-26T02:08:06.673Z (1 day ago) Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin x64 23.4.0

Steps to reproduce the issue:

Background: tinyplot is a lightweight extension of the base R graphics system. It supports features like grouping with automatic legends, faceting, etc. Behind the scenes, this (potentially) requires adjusting plot margins to draw an automatic legend outside of the plot region.

install.packages("tinyplot")
library(tinyplot)

plt(Sepal.Length ~ Petal.Length, data = iris)            # works
plt(Sepal.Length ~ Petal.Length | Species, data = iris)  # blank plot (legend is supposed to be outside the margin)

# Aside: forcing the automatic legend to be drawn _inside_ the plot region works
plt(Sepal.Length ~ Petal.Length | Species, data = iris, legend = "bottomright")

What did you expect to happen?

The second plot (with the legend in the adjusted margin) should be displayed in the plot viewer.

plt(Sepal.Length ~ Petal.Length | Species, data = iris) 

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

No.

Possibly related to https://github.com/posit-dev/positron/issues/3562

P.S. Positron looks very interesting. Thanks!

DavisVaughan commented 5 months ago

Thanks for our first external issue!

There is definitely something wrong with our plot handling when par() is involved. We'll probably take a stab at fixing this after useR.