Density plot draws unwanted outlines (similar to previously-removed release of ggplot2)
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
A density plot created with ggplot2 which has no outline then has an outline drawn when used with ggplotly. Relevant changelog for ggplot2.
Simple version of minimal reprex:
mtcars <- mtcars
p <- ggplot(mtcars, aes(x=disp)) + geom_density()
ggplotly(p)``

A workaround for this simple example (proposed by MrFlick on stackoverflow) was to use stat_density :
p <- ggplot(mtcars, aes(x=disp)) + stat_density(geom="line")
ggplotly(p)``

However, my 'real' data has multiple groups with different distributions. In this case, ggplotly still draw the unwanted outline, but also cannot be fixed this time by stat_density. Example:
p <- ggplot(mtcars, aes(x=disp, group=carb, color=carb)) + geom_density()
ggplotly(p)
p2 <- ggplot(mtcars, aes(x=disp, group=carb, color=carb)) + stat_density(geom="line")
ggplotly(p2)

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 minimal reprex with ggplot2 and ggplotly, then compare the single-group and grouped density examples with the stat_density workaround. Done means ggplotly no longer draws unwanted outlines for density plots, including grouped distributions.
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
- 38/100