rggplot2ecdf

ecdf plot error in ggplot2: unknown color name


I get an error with a very simple ecdf plot in ggplot. Error in color name.

    library(ggplot2)

ggplot(iris) +
  stat_ecdf(aes(x = Sepal.Length,
                col = Species),
            geom = "point")


Error: Unknown colour name: setosa

Solution

  • sometimes happened to me with no apparent cause, but I solved it just forcing Species to be Factor.

    Try this:

            library(ggplot2)
    
    ggplot(iris) +
      stat_ecdf(aes(x = Sepal.Length,
                    col = as.factor(Species)),
                geom = "point")