Shiny plotlyOutput() not responding to height and width sizes

Viewed 19247

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, for instance, I am setting the width and height parameters to 1400px. However, even when I change these values (say to 800px), it does not seem to make any change in the size of the plotly scatterplot.

library(plotly)
library(shiny)
library(ggplot2)

set.seed(1)
dat <- data.frame(ID = paste0("ID", 1:100), x = rnorm(100), y = rnorm(100), stringsAsFactors = FALSE)

ui <- shinyUI(fluidPage(
  titlePanel("title panel"),
  sidebarLayout(position = "left",
  sidebarPanel(width=3,
    actionButton("goButton", "Action")
   ),
  mainPanel(width=9, 
    plotlyOutput("scatMatPlot", width = "1400px", height = "1400px")
  )
  )
))

server <- shinyServer(function(input, output, session) {
  p <- ggplot(data= dat, aes(x=x, y=y)) + geom_point() + coord_cartesian(xlim = c(-5, 5), ylim = c(-5, 5)) + coord_equal(ratio = 1) 
  p2 <- ggplotly(p)
  output$scatMatPlot <- renderPlotly({p2})
})

shinyApp(ui, server)

I tried other size values than "1400px". For instance, I tried "auto" and "100%" - but these did not seem to make a difference either. How can I change the size of the plotly scatterplot in this MWE? Thank you for any input.

2 Answers
Related