Feels related to #2466.
If the {ggplot2} facility to bind a custom scale to muiltiple aesthetics is used, the legend is dropped when the plot is converted plotly.
Reprex:
library(plotly)
library(ggplot2)
library(palmerpenguins)
p <-
penguins |>
ggplot(aes(
x = body_mass_g,
y = bill_length_mm,
colour = species,
fill = species
)) +
geom_point() +
scale_colour_manual(
values = c(
"Adelie" = "red",
"Chinstrap" = "green",
"Gentoo" = "blue"
),
aesthetics = c("colour", "fill")
)
ggplotly(p)
# plot has no legend
Legend appears if we remove references to "fill" and only use "colour".