plotly / plotly.R

An interactive graphing library for R
https://plotly-r.com
Other
2.57k stars 627 forks source link

ggplotly does not respect the labels argument in ggplot2:scale_fill_manual #1930

Open davidhodge931 opened 3 years ago

davidhodge931 commented 3 years ago

ggplotly does not respect the labels argument in ggplot2:scale_fill_manual.

library(tidyverse)

plot_data <- ggplot2::diamonds %>%
  mutate(cut = stringr::str_to_sentence(cut)) %>%
  group_by(cut, clarity) %>%
  summarise(average_price = mean(price)) %>%
  mutate(average_price = round(average_price / 1000, 1)) %>%
  ungroup()

plot <- ggplot(data = plot_data, aes(average_price, cut, fill = clarity)) + 
  geom_col() +
  coord_flip() +
  scale_fill_manual(values = viridis::viridis(8), labels = LETTERS[1:8])

plot

plotly::ggplotly(plot)
davidhodge931 commented 3 years ago

https://github.com/ropensci/plotly/issues/1930