Bug with ggplot2 stat_ecdf() function

When I try to display a ecdf ggplot, it seems that plotly doesn’t work.

With any data (I think), when doing :
ecdf=ggplot(rg, aes(RR)) + stat_ecdf()
ecdf

It is OK to see the graphic. However ggplotly(ecdf) will display a very different plot.

I’m having the same issue. Have you alredy solved it?

I scratched my head over this for a while. A hack fix is to sort the data.frame by the observation.

I have provided code to demonstrate this fix:
library(ggplot2)
library(plotly)

# Set up
animals <- c("duck", "llama", "python")
n <- 50
animals_sd <- seq_along(animals)^2
a <- data.frame(anim = rep(animals, each = n), size = rpois(length(animals) * n, rep(animals_sd, each = n)))

# Works fine in ggplot2
(gg <- ggplot(a, aes(x = size, colour = anim) ) +
    stat_ecdf())
# but ggplotly messes it up
ggplotly(gg)

https://trickytank.github.io/webhelp/plotly/ecdf_animals_broken.html

# This can be fixed by sorting by the x aesthetic:
b <- a[order(a$size), ]

(gg_sort <- ggplot(b, aes(x = size, colour = anim) ) +
        stat_ecdf())
ggplotly(ge_sort)

https://trickytank.github.io/webhelp/plotly/ecdf_animals_working.html

I really think it still looks better with the normal R plot