Is there a way to save a ggplot twice to different file formats with just one ggsave command? Eg plot.pdf and plot.png
You could use mapply()
in this way:
#Code
mapply(function(x) ggsave(x,plot = Yourplot,width = 25, height = 18, units = 'cm'),
x=c('plot.pdf','plot.png'))
An option with tidyverse
would be
library(purrr)
library(ggplot2)
map(c('plot.pdf', 'plot.png'), ~ ggsave(.x, plot = Yourplot, width = 25,
height = 18, units = 'cm'))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.