I\'m trying to make a similar plot to Fig. 2d-f in an article published on Nature this year. It\'s basically a half boxplot with points on the other half.
Can anyone
I find this hybrid boxplot very, very lovely so I wanted to recreate it too.
I wrote a geom_boxjitter that inherits from geom_boxplot and only adds minor changes:
geom_rect only on the left half. errorbar.draw is set to TRUE. Their length
can also be adjusted.You can check the code here. I think it is great how easy it has become to alter existing geoms with slight changes. Using part of your data:
library(tidyverse)
library(cowplot)
library(ggparl)
P <- ggplot(
dat_long %>% filter(key %in% c("p1", "p2")),
aes(x = type, y = value, fill = key)) +
geom_boxjitter(outlier.color = NA, jitter.shape = 21, jitter.color = NA,
jitter.height = 0.05, jitter.width = 0.075, errorbar.draw = TRUE) +
theme(legend.position = "none") +
ylim(c(-0.05, 1.05)) +
scale_fill_manual(values = c("#ecb21e", "#812e91"))
P