I am using ggplot scale_manual to extend legend items to include values absent in the data and it works. However, when I use ggploty to render it, it doesn't work. Is there a work around this?
lims <- c("4", "6", "8", "10")
cols <- c("4" = "blue", "6" = "darkgreen", "8" = "red", "10" = "orange")
labs <- c("4" = "four", "6" = "six", "8" = "eight", "10" = "ten")
p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point(aes(color = factor(cyl)))
q <- p +
scale_color_manual(name = "Cylinder", values = cols, labels = labs, limits = lims)
# This extends the legend items by including "ten".
q
# In this case, the added legend item "ten" is dropped.
ggplotly(q)