【问题标题】:Rmarkdown plotly figures side by sideRmarkdown plotly figures side by side
【发布时间】:2022-12-02 09:57:05
【问题描述】:

I want two figures to appear side by side using .

{r}
library(plotly)
{r, figures-side, fig.show="hold", out.width="50%"}
plot_ly(x = iris$Species, y = iris$Sepal.Length, type = "bar")
plot_ly(x = iris$Species, y = iris$Petal.Length, type = "bar")

When I knit this, the figures appear on different lines. How can I make them side by side?

【问题讨论】:

    标签: ploty r markdown r plotly r-markdown


    【解决方案1】:

    One way would be to not rely on markdown to plot the figures side by side but do it explicitly via plotly. Here's an option with subplot function.

    library(plotly)
    plotly::subplot(plot_ly(x = iris$Species, y = iris$Sepal.Length, type = "bar"),
                    plot_ly(x = iris$Species, y = iris$Petal.Length, type = "bar"), 
                    nrows = 1)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-27
      • 2010-09-11
      • 1970-01-01
      • 2020-03-23
      • 2013-09-15
      • 2016-08-30
      相关资源
      最近更新 更多