I know that there are similar questions already answered on stackoverflow. But, unfortunately, they do not work for me. I am using plotlyOutput()
instead of plotOutput()
, and following is how I have tried to change the height of a fluidRow()
:
fluidRow(
plotlyOutput("plot", height = 200)
)
Or,
fluidRow(
plotlyOutput("plot"),
div(style = "height:200px;")
)
However, nothing changes in my Shiny app. Is there any other option to change the height?
I figured out the solution! It should be like this:
ggplotly(gg1, width = 1400, height = 300)
If you want ggplotly()
to be aware of it's container's size in shiny, you can do this:
library(shiny)
library(plotly)
ui <- fluidPage(
plotlyOutput("pid")
)
server <- function(input, output, session, ...) {
# to relay the height/width of the plot's container, we'll query this
# session's client data http://shiny.rstudio.com/articles/client-data.html
cdata <- session$clientData
output$pid <- renderPlotly({
p <- ggplot(iris) +
geom_point(aes(Sepal.Length, Sepal.Width)) +
facet_wrap(~Species)
ggplotly(p, width = cdata$output_pid_width, height = cdata$output_pid_height)
})
This file has been truncated. show original
4 Likes