Search code examples
rggplot2shinyplotlyggplotly

Display ggplotly chart without toolbar


I am trying to hide the plotly toolbar when displaying a reactive ggplot chart within a Shiny app. Currently my code looks like this:

renderPlotly( ggplot(users_activated(), aes(x = month, y = n)) +
geom_bar(stat = "identity"))

I have tried config(displayModeBar = F) to no avail.


Solution

  • You need to convert your ggplot object to a plotly object before you can render it as one, or use plotly functions on it. ggplotly does that. Below, is an example using mpg dataset.

    ggplotly(ggplot(mpg, aes(class, displ, color = manufacturer)) +
      geom_point()
      ) %>% 
      config(displayModeBar = F)