ggplotly preserve two categorical legends ggplot R

153 views Asked by At

Edit

It turns out this is still a dupe of that question...several years later.

Original question

This is related to this question, but that is a few years old and was not easy to find.

Basically when ggplotly translates a ggplot2 plot, it combines the two legends and creates one combined legend that is not that usable.

Repeatable example:

library(ggplot2)
library(plotly)
data(mtcars)
#two separate legends, as expected
p <- ggplot(mtcars, aes(x = mpg, y = hp, 
                       colour = factor(am), shape = factor(carb))) +
  geom_point()

#one combined, not-usable legend.
ggplotly(p)
0

There are 0 answers