plotly.R icon indicating copy to clipboard operation
plotly.R copied to clipboard

Since ggplot2 4.0.0, theme_bw() looks like theme_minimal()

Open splendiduser opened this issue 2 months ago • 1 comments

As stated in the title, since I updated ggplot2 to version 4.0.0, theme_bw() and theme_minimal() look almost the same - the frame in theme_bw() is missing. This only happens in combination with plotly (version 4.11.0). Downgrading to ggplot2 version 3.5.2 solves this for now. Below is a reproducible example:

library(ggplot2)
library(plotly)

# UI
ui <- fluidPage(
  mainPanel(
    plotlyOutput("plot1"),
    plotlyOutput("plot2")
  )
)

# Server
server <- function(input, output) {
  output$plot1 <- renderPlotly({
    ggplotly(
      ggplot(mtcars, aes(x = wt, y = mpg)) +
        ggtitle("theme_bw") +
        geom_point() +
        theme_bw()
    )
  })
  
  output$plot2 <- renderPlotly({
    ggplotly(
      ggplot(mtcars, aes(x = wt, y = mpg)) +
        ggtitle("theme_minimal") +
        geom_point() +
        theme_minimal()
    )
  })
}

# Run app
shinyApp(ui = ui, server = server)

ggplot2 version 4.0.0: Image

ggplot2 version 3.5.2: Image

splendiduser avatar Oct 08 '25 12:10 splendiduser

Thanks for reporting, I'm also experiencing the same issue

ggabernet avatar Oct 27 '25 15:10 ggabernet