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

svglite does not work with saving a plot made with {ggblend} #184

Closed
davidhodge931 opened this issue Nov 28, 2024 · 2 comments
Closed

svglite does not work with saving a plot made with {ggblend} #184

davidhodge931 opened this issue Nov 28, 2024 · 2 comments

Comments

@davidhodge931
Copy link

When I try run the following code, it just stalls until my Rstudio crashes

library(tidyverse)
library(palmerpenguins)
library(ggblend)
library(svglite)

f <- fs::path("test", ext = "svg")
svglite("test.png")

penguins |>   
	ggplot() +
	blend(geom_density(aes(x = flipper_length_mm, fill = species)), blend = "multiply")

dev.off()
@davidhodge931
Copy link
Author

Realised this relates to #174

@trevorld
Copy link
Contributor

trevorld commented Nov 29, 2024

When I try run the following code, it just stalls until my Rstudio crashes

If in the {ggblend} geom function you return a gTree() with a cl class argument and then add a grid::makeContent() S3 method for that class you can check at draw time if the active graphics device supports the features you need and if not throw a more user friendly error (or downgrade to a fallback approach).

However the fact that running your code with {svglite} makes RStudio stall and crash might be a bug. However I speculate this may not be a bug in {svglite} itself but instead may be a bug in base R or a bug in RStudio? In @pmur002's report about the new features he mentions:

> The remainder of the graphics devices in {grDevices} will run, but will (silently) not produce the correct output.

R knows that {svglite} doesn't support the features introduced in R 4.2 (since the device hasn't told it does as confirmed by dev.capabilities()) so I would speculate that when running your code with {svglite} then it should theoretically run but silently not produce the correct output?

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