When I switch from ggplot to ggplotly, "Virginica" seems to be duplicate with an horizontal line at 0.
data(iris)
library(plotly)
library(ggplot2)
plot_iris <- ggplot(iris, aes(x=Petal.Width, color = Species))+geom_density(aes(y = stat(count)))
ggplotly(plot_iris)
We see 2 blue lines, one of which is at 0 but with a good count. How can I remove this line ?
The problem can be resolved by specifying geom = 'line'
inside stat_density
:
plotly::ggplotly(
ggplot(iris, aes(x = Petal.Width, color = Species)) +
stat_density(geom = 'line')
)