plotly.R
plotly.R copied to clipboard
Density plot draws unwanted outlines (similar to previously-removed release of ggplot2)
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)
Ancient issue, I know, but..
p <- ggplot(mtcars, aes(x=disp, group=carb, color=carb)) +
stat_density(geom="line", position="identity")
ggplotly(p)
Ancient issue, I know, but..
p <- ggplot(mtcars, aes(x=disp, group=carb, color=carb)) + stat_density(geom="line", position="identity") ggplotly(p)
This works, thanks!