I kind of stuck how to obtain ECDF (line and point combined together) plot using more than 1 aes (could be color, linetype for geom_line
or shape for geom_point
).
So, I have this code for example
data<-mtcars
data$cyl<-as.factor(data$cyl)
data$am<-as.factor(data$am)
ggplot(data,aes(qsec))+
geom_line(stat = "ecdf",aes(linetype=cyl))+
geom_point(stat="ecdf",size=2,aes(shape=cyl))+
labs(x="sample")+
theme(axis.title.y = element_blank(),
text = element_text(size = 11, family = "serif"))+
scale_y_continuous(labels = function(x) paste0(sprintf("%1.0f", x*100),"%"))+
scale_x_log10(breaks = trans_breaks("log10", function(x) 10^x),
labels = trans_format("log10", math_format(10^.x))
)
It is nicely formed ECDF plots by cyl type
But, then I wanted to mark some points based on am
category, with adding color=am within the aes of geom_point
, then the results were seemingly randomly scattered
I guess, it is because I used ECDF so, it created new individual cumulative calculations based on new category I've created. Could anybody help me out here? thanks