【问题标题】:Save ggplot with twice with different file formats with ggsave (ggplot2)使用 ggsave (ggplot2) 以不同的文件格式保存 ggplot 两次
【发布时间】:2020-12-10 14:29:58
【问题描述】:

有没有办法用一个 ggsave 命令将 ggplot 两次保存为不同的文件格式?例如。 plot.pdf 和 plot.png

【问题讨论】:

    标签: r ggplot2 ggsave


    【解决方案1】:

    你可以这样使用mapply()

    #Code
    mapply(function(x) ggsave(x,plot = Yourplot,width = 25, height = 18, units = 'cm'),
           x=c('plot.pdf','plot.png'))
    

    【讨论】:

      【解决方案2】:

      tidyverse 的选项是

      library(purrr)
      library(ggplot2)
      map(c('plot.pdf', 'plot.png'), ~ ggsave(.x, plot = Yourplot, width = 25,
                   height = 18, units = 'cm'))
      

      【讨论】:

        猜你喜欢
        • 2016-03-12
        • 1970-01-01
        • 2011-10-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-02-11
        • 1970-01-01
        相关资源
        最近更新 更多