Last active
October 24, 2022 10:07
-
-
Save knbknb/f2e2c635fc7ec656efac39cf94d7f68c to your computer and use it in GitHub Desktop.
R: save plot as SVG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
# save an image object created with "ggplot2" to svg file | |
# runs on linux | |
myplot_svg <- "myplot.svg" | |
image <- ggplot() + | |
geom_col(aes(x= symb,y=v,fill=symb))+ | |
theme(axis.text.x = element_text(angle=90)) + | |
labs(title='Some title', subtitle=sprintf('%s',date())) + | |
facet_wrap(~ k, scales='free'); | |
ggsave(filename=myplot_svg, plot=image, width=10, height=8) | |
# optional | |
# system(glue::glue('firefox "{myplot_svg}" &') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment