plotly / plotly/plotly.R

Density plot draws unwanted outlines (similar to previously-removed release of ggplot2)

Open
#1,968 2 comments 0 reactions 0 assignees View on GitHub

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)``

image

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)``

image

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)

image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.