1

I would like to create a stripchart that looks like this:

enter image description here

But I was only able to create something similar using stat_summary crossbar:

ggplot(data, aes(x=variable, y=value)) + 
stat_summary(fun.data="mean_sdl", fun.args = list(mult=1), geom="crossbar", width=0.5) +
geom_jitter(position=position_jitter(0.2))

The result is this:

enter image description here

I would be grateful for any advice on how to modify the code so I can get a graph like in the first image.

Axeman
  • 32,068
  • 8
  • 81
  • 94
joker33
  • 33
  • 5

2 Answers2

3

You can use the beeswarm package:

library (beeswarm)

beeswarm(len ~ dose, data = ToothGrowth, 
    col = 4, pch = 16,
    main = 'beeswarm + bxplot')
  bxplot(len ~ dose, data = ToothGrowth, add = TRUE)

enter image description here

Axeman
  • 32,068
  • 8
  • 81
  • 94
Edward
  • 10,360
  • 2
  • 11
  • 26
3
ggplot(mtcars, aes(factor(cyl), qsec)) +
    geom_jitter(position = position_jitter(width = 0.2)) +
    stat_summary(fun.data = 'mean_sdl', geom = 'errorbar', width = 0.3) +
    stat_summary(fun.y = mean, geom = 'point', size = 20, shape = '_')

enter image description here

Axeman
  • 32,068
  • 8
  • 81
  • 94