const-ae/ggsignif

ggsignif facetting issue - Missing significance labels in certain facets

Opened this issue · 0 comments

The significance label does not appear in facets where one group in the comparison list is missing (facet 'C' and 'E' in example).

Refer below (plot and code):

2024-05-17_example-boxplot-ggsignif

`data_example <- data.frame(matrix(ncol = 0, nrow = 2400))`

`data_example <- data_example %>%
 dplyr::mutate(
GROUP = rep(LETTERS[1:6], each = 100),
NUMERIC = sample(1:1000, 600, replace = TRUE), 
STATUS = case_when(GROUP == 'E' ~ rep(c('Good', 'Bad'), length.out = 600), GROUP == 'C' ~ rep(c('Neutral', 'Good'), length.out = 600),
TRUE ~ rep(c('Good', 'Bad', 'Neutral'), length.out = 600))
) `

`boxplot <- ggplot(data = data_example) + geom_boxplot(aes(x = STATUS, y = NUMERIC, fill = STATUS), color = "black", alpha = 0.7, position = position_dodge(width = 0.75)) + 
geom_point(aes(x = STATUS, y = NUMERIC, color = STATUS), position = position_jitterdodge(jitter.width = 0.2, dodge.width = 0.75),  size = 2, alpha = 0.2) + 
stat_signif(comparisons = list(c("Good", "Neutral"), c("Good", "Bad"), c("Neutral", "Bad")), aes(x = STATUS, y = NUMERIC), step_increase = 0.1, map_signif_level = TRUE) + 
facet_wrap(. ~ GROUP) + 
scale_x_discrete() + 
scale_y_log10(breaks = c(10^(-1:6)), minor_breaks = c(1:9 %o% 10^(-1:6)), labels = c('0.1', '1', "10", "100", "1'000", "10'000", "100'000", "1'000'000")) +
 labs(y = 'Numeric', x = 'Status') + 
theme_bw(base_size = 14) + 
theme(legend.position = "null")`

Thank you