wudl-21
wudl-21

Reputation: 51

Transparent R plot background in VS Code Jupyter Notebook - How to set default white background?

original issue on Github

Issue Description:

When generating R plots in VS Code's Jupyter Notebook (.ipynb files), the plot backgrounds appear transparent by default, making visualizations hard to read. This issue:

Minimal Reproducible Example:

x <- c(1, 2, 3, 4, 5)
y <- c(2, 4, 6, 8, 10)

plot(x, y, type = "o", col = "blue", pch = 16, main = "Simple Plot")
legend("topleft", legend = "y = 2x", col = "blue", pch = 16, lty = 1)

transparent_bg

Expected vs Actual Behavior:

Result
Expected White background (as in .R files)
Actual Transparent background

Temporary Workaround:

par(bg = "white")  # Required before each plot
plot(...)  

white_bg

Environment:

Additional Context:

Question:

Upvotes: 2

Views: 44

Answers (0)

Related Questions