Skip to content

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

@wcwr

Description

@wcwr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions