One possible option is to jitter
the data points so that they no longer overlap so heavily. This also avoids the need to bin the y-axis and use a stacked dotplot. It's not perfect but it's useful for representing the spread of your data, which it seems like the points atop the boxplot is intended to do.
cp <- readr::read_table("id val tag
id1 12.60 A
id2 12.48 A
id3 12.48 B
id4 13.95 B
id5 12.60 A
id6 12.48 A
id7 11.13 A
id8 9.56 A
id9 10.32 B
id10 9.569 B")
cp$tag <- factor(cp$tag)
# cp$val <- jitter(cp$val, amount = 0.5)
ggplot(cp, aes(x=tag, y=val,label=id)) +
geom_boxplot() +
geom_point(size=3) +
geom_text_repel(arrow = arrow(length = unit(0.02, "npc")),box.padding = 1) +
theme_bw()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…