【问题标题】:Is there a way of increasing resolution and width of ggplots when knitting an R script without writing it in R Markdown?在编写 R 脚本而不用 R Markdown 编写它时,有没有办法增加 ggplots 的分辨率和宽度?
【发布时间】:2023-03-26 10:58:01
【问题描述】:

我有一个纯 R 脚本,不是使用 R Markdown 编写的。在其中,我使用 ggplot 创建了几个图表。然后我通过 File > Knit Document 编织脚本。

我的输出有两个问题。首先,这些图没有输出的其余部分那么宽。其次,地块的分辨率不是很好。

有什么方法可以增加图形的宽度和分辨率,而无需使用 R Markdown 重写脚本?

【问题讨论】:

    标签: r ggplot2 width knitr resolution


    【解决方案1】:

    您可以使用knitr spin syntax 为您的绘图提供块选项。这应该会增加它们的宽度(并且可能还会解决分辨率问题):

    #+ fig.width = 3
    plot(1) # narrow plot
    
    #+ fig.width = 9
    plot(1) # wide plot
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-29
      • 2017-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-20
      • 1970-01-01
      相关资源
      最近更新 更多