I have been working on a shiny app for some time, last week I updated all of my packages when I downloaded a new version of RStudio. All of a sudden, existing shiny themes will work outside of ggplotly but not within. I really just want the panel border to show up black but I can't add it as a theme element.
Ex This works and has a border
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_bw()
This has no border...?
ggplotly(
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_bw())
This also has no border
ggplotly(
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_bw() +
theme(panel.background = element_rect(fill = NULL, colour = "black")))
Any insight would be appreciated!
Edit: R Studio Version: 2025.09.0-387 ggplot2: 4.0.0 plotly: 4.11.0
There has been a change. In ggplot2 version ‘3.5.2‘ & plotly version ‘4.11.0’
ggplotly(
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_bw()
)
produces this plot
If you want to roll back to this package version, you can do so like this:
remotes::install_version("ggplot2", version = "3.5.2", repos = "http://cran.us.r-project.org")
Here you have a list of mirrors for R.
whereas with the newer ggplot version ‘4.0.0.9000‘ the outer borders from panel.background are not translated to plotly
but we can manually bring them back using the layout for both axis
ggplotly(
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
theme_bw()) |>
layout(
xaxis = list(showline = TRUE, linecolor = "black", linewidth = 0.66, mirror = TRUE),
yaxis = list(showline = TRUE, linecolor = "black", linewidth = 0.66, mirror = TRUE)
)
giving

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With