ggpubr
ggpubr copied to clipboard
stat_compare_means() tip.length absolute values?
The docs indicate that tip.length
specifies "the fraction of total height that the bar goes down to indicate the precise column." Apparently, the tip.length
is relative to the bar length (see example).
Is there any way (or workaround) to achieve "constant" tip length for stat_compare_means()
, e.g. by making it relative to the y axis range?
Example:
library(ggpubr)
# I want these tip length to be always the same, regardless of the bars
make_standardized_plot <- function(data) {
ggbarplot(data, x = "treatment", y = "value", add = "mean_se") +
stat_compare_means(comparisons = list(c("a", "b")), tip.length = 0.2, label.y = 19) +
ylim(0, 20)
}
data_1 <- data.frame(treatment = c("a", "a", "a", "b", "b", "b"), value = c(1, 2, 4, 3, 5, 6))
data_2 <- data.frame(treatment = c("a", "a", "a", "b", "b", "b"), value = c(1, 2, 4, 12, 14, 15))
p1 <- make_standardized_plot(data_1)
p2 <- make_standardized_plot(data_2)
print(ggarrange(p1, p2))
+1, I actually only realized for a manuscript revision and didn't find a fix, so having to edit all individual tips now in Inkscape, which is what I am trying to avoid using ggpubr ;)
Would be great to have different options. For me actually a fraction of total plot height would work best as I have plot with different scales but these should all end up with the same tip length in the end.