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

ggplot2 does not show in VSCode in the plot viewer when sourcing the entire script #6363

Closed
mzavattaro opened this issue Mar 15, 2025 · 2 comments

Comments

@mzavattaro
Copy link

mzavattaro commented Mar 15, 2025

I've discovered if I run a script line by line (e.g. Ctrl+Enter) in VSCode that has a plot call ggplot(data = complete_old, mapping = aes(x = weight, y = hindfoot_length, color = plot_type)), VSCode will automatically open the plot viewer; but if I source the entire script (e.g. Ctrl+Shift+S or clicking on the '>' in the top right corner), the plot viewer does not open.

If I wrap it in a print(ggplot(...)) and source the entire script, then VSCode will open the plot viewer.

I know that I can manually open the interactive window by inputting .vsc.attach() into the R console, but it still shows nothing if the script was sourced rather than ran line-by-line.

I've also tried this with httpgd and including the VSCode setting "r.plot.useHttpgd": true,, but this also doesn't work either when sourcing the entire script.

I am using the R extension for VSCode as well.

I would have thought that I didn't need to wrap it in a print(...) when sourcing the entire script?

@teunbrand
Copy link
Collaborator

I know nothing about VSCode and how it interacts with graphics devices. Is this a ggplot2 specific problem, or does the same happen with base graphics? If this doesn't happen with base graphics, does it happen with grid/lattice graphics?

@teunbrand
Copy link
Collaborator

I think this issue will get a better audience at a different venue like stackoverflow or the posit community. I'm not aware of any other ggplot2 developer that uses VSCode. In contrast, I expect R users with ggplot2 experience that work in VSCode to be a much larger group. They might be able to provide better help than we can.

@teunbrand teunbrand closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants