Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Positron creates blank plot for multiple ggplot-objects composed with the "patchwork" package #4593

Open
Tracked by #4734
strengejacke opened this issue Sep 6, 2024 · 5 comments
Labels
area: plots Issues related to Plots category. bug Something isn't working lang: r support

Comments

@strengejacke
Copy link

strengejacke commented Sep 6, 2024

System details:

Positron and OS details:

Positron Version: 2024.09.0 (system setup) build 1
Code - OSS Version: 1.92.0
Commit: f37f4f5
Date: 2024-09-03T02:35:34.573Z
Electron: 30.1.2
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631

Interpreter details:

R 4.4.1

Describe the issue:

The output of the function performance::check_model() produces a blank screen (plot) instead of the desired plot. The function creates 6 ggplot-objects, which are then composed using the patchwork package.

Steps to reproduce the issue:

library(performance)
data(mtcars)
m <- lm(mpg ~ gear + cyl + hp, data = mtcars)
check_model(m)

The single plots (ggplots) can be obtained by setting panel = FALSE. Each single plot is correctly plotted in Positron, however, patchwork::wrap_plots() produces a blank plot:

library(performance)
data(mtcars)
m <- lm(mpg ~ gear + cyl + hp, data = mtcars)

p <- plot(check_model(m), panel = FALSE)
p[[1]] # works
p[[2]] # works

# blank plot
patchwork::wrap_plots(p)

Expected or desired behavior:

Screenshot VSCode

image

Screenshot RStudio

image

Were there any error messages in the UI, Output panel, or Developer Tools console?

I couldn't find anything conspicuous in the logs, maybe you can point me to where I find the relevant information for you.

@strengejacke
Copy link
Author

Note that this example works in Positron:

library(ggplot2)
p1 <- ggplot(iris, aes(Sepal.Width, Sepal.Length)) + geom_point()
p2 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) + geom_point()
p3 <- ggplot(iris, aes(Sepal.Width, Sepal.Length)) + geom_line()
p4 <- ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) + geom_line()

patchwork::wrap_plots(list(p1, p2, p3, p4))

Created on 2024-09-06 with reprex v2.1.1

@strengejacke
Copy link
Author

I could narrow this down. The problem seems to be when ncol is defined:

library(performance)
data(mtcars)
m <- lm(mpg ~ gear + cyl + hp, data = mtcars)

p <- plot(check_model(m), panel = FALSE)
# works in Positron
patchwork::wrap_plots(list(p[[1]], p[[2]]))
# works in Positron
patchwork::wrap_plots(list(p[[1]], p[[2]], p[[3]], p[[4]]))
# works in Positron
patchwork::wrap_plots(list(p[[1]], p[[2]], p[[3]], p[[4]], p[[5]], p[[6]]))
# blank plot!!!
patchwork::wrap_plots(list(p[[1]], p[[2]], p[[3]], p[[4]], p[[5]], p[[6]]), ncol = 2)

@testlabauto
Copy link
Contributor

Hi @strengejacke, thank you for your bug report and for your work narrowing down the issue.

I am able to reproduce this on my end. We will look into the problem further!

@testlabauto testlabauto added the area: plots Issues related to Plots category. label Sep 6, 2024
@juliasilge juliasilge added bug Something isn't working support lang: r labels Sep 6, 2024
@juliasilge juliasilge added this to the Release Candidate milestone Sep 9, 2024
@juliasilge
Copy link
Contributor

@strengejacke
Copy link
Author

Ok. Feel free to close in favor of the other related issue(s), unless you'd like to keep this open for the example.

@DavisVaughan DavisVaughan mentioned this issue Sep 18, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: plots Issues related to Plots category. bug Something isn't working lang: r support
Projects
None yet
Development

No branches or pull requests

3 participants