【问题标题】:R code in R-Studio to save the graph as .jpeg or .pngR-Studio 中的 R 代码将图形保存为 .jpeg 或 .png
【发布时间】:2021-12-30 11:03:41
【问题描述】:

当我使用 R 时,可以通过将文件保存为单击另存为 .jpeg 来保存图形。

但是,我无法在 R studio 中那样保存。因此,我进行了搜索,但无法获得将图形另存为 .jpeg 或 .png 的代码。

任何人都可以帮忙并提供它的代码吗?

这将是一个很大的帮助。 谢谢你

【问题讨论】:

    标签: r png jpeg


    【解决方案1】:

    通过 ggplot 你可以使用函数ggsave()

    library(ggplot)
    
    df = iris
    
    ggplot(data=df, aes(x=Species, y=Sepal.Width)) + geom_point(aes(color=Species, shape=Species))
    
    ggsave("iris.png", width = 4, height = 4, dpi=300)
    

    【讨论】:

      猜你喜欢
      • 2017-04-16
      • 2021-10-11
      • 2016-01-28
      • 1970-01-01
      • 2011-12-30
      • 1970-01-01
      • 2015-09-28
      • 1970-01-01
      相关资源
      最近更新 更多