在闪亮的RMD中工作时,是否有R-way将Plotly窗口高度设置为100%?
我正在使用RMD文件开发交互式报告,该报告指定了闪亮的运行时。但是,我遇到了以下问题。
当绘制具有较大高度规格的GGPLOTS时,它们会开始覆盖HTML输出的其他方面(例如在Exaple中,此处为文本)。到目前为止,我的研究已经产生了Poltly容器中的固定设置 Height == 400px
对此负责。
---
runtime: shiny
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
library(tidyverse)
library(shiny)
library(plotly)
```
```{r}
fluidRow(
column(3,
selectInput("myselectorID",
"Select:",
selected = "setosa",
choices = c("setosa", "versicolor", "virginica")))
)
renderPlotly({
data <- iris %>% filter(Species == input[["myselectorID"]])
ggp <- data %>% ggplot(aes(x = Sepal.Length, y = Sepal.Width)) +
geom_point()
ggplotly(ggp, height = 487)
})
```
START
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT
END
如果我提供以下 css
(例如,通过yaml标头),则该问题已经解决:
.plotly {
height: 100% !important;
}
我更喜欢将参数传递到r函数的解决方案。有什么想法吗?谢谢你!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有人回答了这一点,并删除了他们的答案……不确定为什么,但这是他们为记录发布的内容,因为它似乎可以解决问题:
Someone answered this and deleted their answer which was working... Not sure why but here's what they posted for the record since it seemed to do the trick:
”上展开扩展
insertui
稍后放置绘图输出,稍后:plotlyoutput()
:示例(插入 id id> id “ some_plots”的三个 ggplotly 输出的三个 ggplotly 输出):
To expand on this solution, you can programmatically insert
ggplotly
outputs of specified heights like this:insertUI
later:plotlyOutput()
:Example (inserting three ggplotly outputs of different heights at id "some_plots"):