Skip to content

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

@splendiduser

Description

@splendiduser

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions