Shiny plotlyOutput() not responding to height and width sizes

前端 未结 2 1141
迷失自我
迷失自我 2021-02-10 03:46

I am creating a Shiny app with a plotly scatterplot. I am trying to keep the scatterplot square-shaped, but want a much larger size than its default. In the simple MWE below, fo

2条回答
  •  庸人自扰
    2021-02-10 04:08

    When you use ggplotly() you can change the size of plotlyOutput with layout options in the server part:

    p2 <- ggplotly(p) %>% layout(height = 800, width = 800)
    

    I found that plotlyOutput will only work with parameters width = "600px", height = "600px" if you provide input directly from plot_ly() instead ggplotly(), e.g.

    p2 <- plot_ly(dat, x = ~x, y = ~y)
    

提交回复
热议问题