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

Error: Unknown graphics device 'svg' #469

Closed
UhuEngelCrash opened this issue May 22, 2022 · 2 comments
Closed

Error: Unknown graphics device 'svg' #469

UhuEngelCrash opened this issue May 22, 2022 · 2 comments

Comments

@UhuEngelCrash
Copy link

The graphics format svg (Scalable Vector Graphics) is a common and widespread graphics format. It has the unique advantage of always being sharp at any resolution. It already exists in R with the svg function. I would be happy if graphics could also be saved as svg files with ggexport in the next version of ggpubr. Thank you if that is possible.

@ceisenhauer
Copy link

as an alternative, since ggpubr produces ggplot objects you can always just save them using ggplot2::ggsave() (which supports svg outbput) instead of ggpubr::ggexport(). for example :

set.seed(1234)
data = data.frame(sex = factor(rep(c("F", "M"),
                                   each = 200)),
                  weight = c(rnorm(200, 55),
                             rnorm(200, 58)))

p <- ggpubr::ggdensity(wdata,
                       x = "weight",
                       add = "mean",
                       rug = TRUE,
                       color = "sex",
                       fill = "sex",
                       palette = c("#00AFBB", "#E7B800"))

ggplot2::ggsave('example_plot.svg', p)

doesn't directly resolve the ggexport() issue, but could be a good option in the mean time.

@UhuEngelCrash
Copy link
Author

Thanks for the note. Yes, this is another workaround besides using the svg() and dev.off() functions directly, which have always been able to generate SVG image files for graphics with ggplot2 and ggpubr. But it is surprising that it is not available in the context of the ggpubr package.

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