I'm trying to use plotly
in an Rmarkdown file, but the plots all get rendered in HTML without occupying the available horizontal space and therefore feel very cramped. I've tried the solution found here (out.width='100%'
), but to no effect:
---
title: "R Notebook"
output: html_notebook
---
[filler text]
```{r, out.width='100%'}
suppressPackageStartupMessages(library(plotly))
plotly::plot_ly() %>%
add_lines(
x = seq(1:1000),
y = runif(1000)
) %>%
layout(
autosize = TRUE
)
```
This gets rendered in HTML (on Chrome) as:
I've also tried calling knitr::opts_chunk$set(out.width = "100%")
directly (in its own chunk before the plot), but to no effect.
Following @Axeman's comment, I also tried setting output: html_document
. This works as far as getting plotly
to fill the horizontal space, but disables table pagination. So my actual use-case, which includes tables with hundreds of lines, becomes unusable, demanding endless scrolling past those tables.
How should this be done?