[英]Save ggplot with twice with different file formats with ggsave (ggplot2)
有沒有辦法用一個 ggsave 命令將 ggplot 兩次保存為不同的文件格式? 例如 plot.pdf 和 plot.png
你可以這樣使用mapply()
:
#Code
mapply(function(x) ggsave(x,plot = Yourplot,width = 25, height = 18, units = 'cm'),
x=c('plot.pdf','plot.png'))
tidyverse
的一個選項是
library(purrr)
library(ggplot2)
map(c('plot.pdf', 'plot.png'), ~ ggsave(.x, plot = Yourplot, width = 25,
height = 18, units = 'cm'))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.