Support ggplot2's custom group labelling
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I found issues related to ggplot2's legend positioning, but couldn't find any addressing the fact that ggplotly ignores group labels changed by scale_color_discrete (or similar).
In contrast, it is able to handle a change in tick labels done in a similar manner using scale_x_discrete. You can find an example below with the iris dataset.
It would be great if you could add support to this!
# change in tick labels supported
gg <- ggplot(iris, aes(x=Species, y=Sepal.Width)) +
geom_boxplot() +
scale_x_discrete(labels=c("a", "b", "c)"))
gg
ggplotly(gg)
# change in group labels not supported
gg <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, group=Species, color=Species)) +
geom_point() +
scale_color_discrete(labels=c("a", "b", "c"))
gg
ggplotly(gg)
Great work!
Mariana Oliveira
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided iris examples with ggplotly and compare the supported scale_x_discrete tick labels with the unsupported scale_color_discrete group labels. Trace how ggplotly converts ggplot2 scales into legend data; done means custom group labels such as "a", "b", and "c" appear in the resulting legend.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100