Closed
Description
geom_dotplot is not laying out the points correctly when there are 2 groups. See http://stackoverflow.com/questions/39375983/geom-dotplot-dot-layout-with-groups
require(data.table)
require(ggplot2)
set.seed(10000)
n <- 300
dt <- data.table(Duration=sample(100:800,n,replace=T), EndType=round(runif(n,min=.4)), Group=sample(c("GrpA","GrpB"),n,replace=T))
dt <- rbind(dt, dt[, -c("Group"), with=F][, Group:="All"])
dt[, ":="(Group=factor(Group, levels=c("All","GrpA","GrpB"), ordered=T), EndType=factor(EndType, levels=c(0,1)))]
g <- ggplot(dt, aes_string(x="Group", y="Duration")) + coord_flip() +
geom_boxplot(aes(ymin=..lower.., ymax=..upper..), fatten=1.1, lwd=.1, outlier.shape=NA) +
geom_dotplot(aes(fill=EndType), binaxis="y", stackdir="center", stackgroups=T, method="histodot", binwidth=15, dotsize=.5) +
scale_fill_manual(values=c("white","black"))
print(g)