Reputation: 556
Using ggplot, I could create my desired plot. However, when I converted to plotly (the code below), I got an error:
Error in renderPlotly({ : unused argument (height = function() {
400 + (length(workforce_data()[["County.y"]]) * 5)
}).
How can I fix this?
plotly code
output$workforce_plot <- renderPlotly ({
workforce_plot()
} , height = function() {400 + (length(workforce_data()[["County.y"]]) *5) })
Upvotes: 0
Views: 548
Reputation: 33397
renderPlotly
doesn't have a height
argument.
However, you can use ggplotly
's height
argument as follows:
library(plotly)
library(shiny)
ui <- fluidPage(
sliderInput("heightSlider", "Plot heigth [px]", min = 200L, max = 1000L, value = 500L),
plotlyOutput("myPlot")
)
server <- function(input, output, session) {
output$myPlot <- renderPlotly({
p <- ggplot(data.frame(x = 1:10, y = runif(10)), aes(x, y)) + geom_point()
ggplotly(p, height = input$heightSlider)
})
}
shinyApp(ui, server)
Upvotes: 1