Search code examples
rplotlyr-markdown

Setting size of plotly widgets in rmarkdown html report


I am saving plotly widgets and then loading them into rmarkdown to be used in html report. The problem is that the plotly widgets are too small. When I open the widgets in an external browser they are of a sufficient size, but I am unsure how to set the eize of the widgets in rmarkdown.

I saving plotly widgets using save(p, "widget.rda") I am then loading the widgets into rmarkdown using load("widget.rda")


Solution

  • Try setting out.width = "100%" in the chunk header like so:

    ```{r out.width = "100%"}
    library(leaflet)
    leaflet() %>% addTiles()
    ```
    

    enter image description here