【问题标题】:Two images side by side in rmarkdown using knitr?使用knitr在rmarkdown中并排的两个图像?
【发布时间】:2020-09-13 01:11:53
【问题描述】:

在 Rmarkdown 中,我想并排打印来自网络的两个图像。我正在尝试这个

```{r, echo=FALSE, out.width="33%", fig.align = "center", fig.cap="Examples of the FPTP bias: In Prairies (left) and Greater Toronto area (right). Source: www.fairvote.ca"}

knitr::include_graphics(
  c("https://www.fairvote.ca/wp-content/uploads/2019/12/Western-alienation-website-FPTP-page.png", "https://www.fairvote.ca/wp-content/uploads/2019/12/Toronto-Peel-halton-2019-results-website-FPTP.jpg")
  )

```

但相反,我得到了这个 - 它们仍然打印在另一个之上:

请指教。注意:我不使用cowplot 或任何其他包。

【问题讨论】:

    标签: r r-markdown knitr


    【解决方案1】:

    包括参数fig.show='hold'

    ```{r, echo=FALSE, out.width="33%", fig.align = "center", fig.show='hold', fig.cap="Examples of the FPTP bias: In Prairies (left) and Greater Toronto area (right). Source: www.fairvote.ca"}
    knitr::include_graphics(
      c("https://www.fairvote.ca/wp-content/uploads/2019/12/Western-alienation-website-FPTP-page.png",
        "https://www.fairvote.ca/wp-content/uploads/2019/12/Toronto-Peel-halton-2019-results-website-FPTP.jpg")
    )
    ```
    

    这是现在的样子:

    【讨论】:

    • 谢谢!仅作记录,R Markdown Cookbook 也涵盖了这个主题:bookdown.org/yihui/rmarkdown-cookbook/figures-side.html
    • 太棒了!非常感谢。有没有办法在图像之间插入字符:比如knitr::include_graphics( "a) ", c("https://www.fairvote.ca/wp-content/uploads/2019/12/Western-alienation-website-FPTP-page.png", "b)" "https://www.fairvote.ca/wp-content/uploads/2019/12/Toronto-Peel-halton-2019-results-website-FPTP.jpg") ) - 所以我们可以将图像称为“参见图 1.b”?
    • @IVIM 不确定这个,我没做过。也许你可以提出一个新问题!
    猜你喜欢
    • 1970-01-01
    • 2015-03-16
    • 2014-10-14
    • 1970-01-01
    • 1970-01-01
    • 2016-03-29
    • 2021-05-15
    • 1970-01-01
    • 2016-09-04
    相关资源
    最近更新 更多