如何使用 rmarkdown 使绘图图表调整到页面宽度? [英] How to make plotly charts adjust to page width using rmarkdown?

查看:98
本文介绍了如何使用 rmarkdown 使绘图图表调整到页面宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一篇 R 博客文章,其中包含一些传单和情节图.我可以在 leaflet() 函数中设置 width = "100%",当我调整浏览器窗口的大小(或在移动设备上查看)时,传单地图会改变形状.我在 plot_ly() 中尝试了相同的 width = "100%",但该图不会为较小的窗口调整大小,并且需要水平滚动.

I have an R blog post with some leaflet and plotly figures. I can set width = "100%" in the leaflet() function, and the leaflet map will change shape as I resize my browser window (or view on mobile). I've tried the same width = "100%" in plot_ly(), but the plot doesn't resize for smaller windows and requires horizontal scrolling.

有什么想法吗?如果有帮助,我正在使用 blogdown/hugo.

Any ideas? I'm using blogdown/hugo if that is helpful.

推荐答案

使用块选项:

```{r, out.width='100%'}

这篇关于如何使用 rmarkdown 使绘图图表调整到页面宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆