如果shiny
r-markdown
报表包含React性plotly
图,如何防止长图(使用ggplotly
生成)重叠?
在示例中,很明显,plotly-long
块中生成的图与下面的块中生成的图重叠。
---
title: "A shiny Report"
runtime: shiny
output:
bookdown::html_document2
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(tidyverse)
library(plotly)
df <- data.frame(type = c("potato", "carrot", "leek"),
count = c(1, 3, 2))
selectizeInput("SELECTION",
"Choose:",
selected = c("potato", "leek"),
multiple = TRUE,
choices = c("potato", "carrot", "leek"))
df_filt <- reactive({
df %>%
filter(type %in% input$SELECTION)
})
ggp <- reactive({
df_filt() %>%
ggplot(aes(y = count, fill = type, x = "a_bar")) +
geom_bar(stat = "identity")
})
renderPlotly({
ggplotly(ggp(), height = 1600)
})
renderPlotly({
ggplotly(ggp())
})
1条答案
按热度按时间2w2cym1i1#
将
renderPlotly
替换为renderUI
就可以做到这一点。