An R package to prepare publication ready plots based on the ggplot2 plotting system.
Questions tagged [ggpubr]
532 questions
4
votes
2 answers
Add custom annotation to p-value label to ggpubr stat_compare_means()
I try to make boxplot with displaying p-value
my_comparisons <- list( c("0.5", "1"), c("1", "2"), c("0.5", "2") )
ggboxplot(ToothGrowth, x = "dose", y = "len")+
stat_compare_means(comparisons = my_comparisons, method = "wilcox.test")
the result…

autumnrustle
- 595
- 1
- 10
- 21
4
votes
2 answers
Iterating over a list using ggarrange
I have the following bit of code and don't understand why the for loop isn't working. I'm new to this, so excuse me if this is obvious, but it's not actually producing a combined set of graphs (as the more brute force method does below), it just…

Skotani1
- 149
- 6
4
votes
1 answer
Animated violin/boxplots plots with p-values for paired Wilcoxon tests
I am trying to add p values for paired wilcox test in R. I am using the following code. The code below creates violins (density distributions) of an outcome reading (bicep) for two diets (treatment). These violins are animated over time 1, time 2,…

DiscoR
- 247
- 2
- 11
4
votes
0 answers
Multi-page output of faceted and aligned plots
I am trying to combine faceted boxplots with equally faceted lineplots, both of which should be properly aligned so that it is clear which plots belong together. I can actually achieve exactly what I want using ggpubr::ggarrange() like this (I will…

Matt Flor
- 641
- 5
- 8
4
votes
1 answer
add adjusted p value to ggplot with comparison
I need help to add the adjusted p value (bonferroni for example) on ggplot boxplot instead of p value. I've try to do it with stat_compare_means from ggpub package by using ..p.adj.. on the aesthetics, but it doesn't work when I add the comparison…

zercchi
- 41
- 1
- 2
3
votes
2 answers
ggpubr::stat_cor(), label.npc doesn't take into account geom_smooth output
library(ggplot2)
library(ggpubr)
data('iris')
ggplot(data = iris, aes(x = Petal.Length, y = Sepal.Length, color = Species))+
geom_point()+
geom_smooth(method = 'lm')+
facet_wrap('Species', scales = 'free')+
stat_cor(aes(color =…

Bryce Cook
- 45
- 4
3
votes
1 answer
In R, what is the best way to add the p-values from comparisons between groups to a grouped bar chart
Please, consider the following MWE.
EDIT: Thanks to the very good comments, it became clear that there were not enough data in my very simplified MWE to do the statistical comparisons between the groups. Due to this shortcoming, I've rewritten the…

jaggedjava
- 440
- 6
- 14
3
votes
3 answers
Add count values on top of gghistogram
I've made a histogram for the different age groups in my data:
> dput(Agedata[1:20,])
structure(list(samples = c("Pt1", "Pt10", "Pt101", "Pt103", "Pt106",
"Pt11", "Pt17", "Pt18", "Pt2", "Pt24", "Pt26", "Pt27", "Pt28",
"Pt29", "Pt3", "Pt30",…

Programming Noob
- 1,232
- 3
- 14
3
votes
2 answers
ggpubr can't find 'mean_se' unless ggpubr is attached via library()
Summary of problem: When I try to add summary stats to a ggpubr plot via the "add" parameter, ggpubr can't find the summary stat functions (example code below). For instance, if I am trying to add error bars with add="mean_se" I get an error message…

Azura's Starfish
- 112
- 1
- 6
3
votes
0 answers
Change size of common legend in ggarrange
I want to create a combined plot with ggarrange and save it as png-file. I tried it with the following code:
png("../graphics/Part1.png", width = 8, height = 20, res=300, units = "cm")
ggarrange(P1, P2, P3, P4, P6,
ncol = 1, nrow = 5,
…

user17821558
- 45
- 3
3
votes
0 answers
annotate facet_grid plot with two-way ANOVA post-hoc results
I have a 2x2 study design (i.e. 4 groups) to test the interaction of two different interventions, and obtain multiple measurements for each subject, measured across different sites. I can nicely plot these data using a facet_grid for the different…

Timmo83
- 119
- 5
3
votes
1 answer
Lollipop chart with repeated elements in different groups
I am trying to plot a lollipop chart with 5 groups and repeated elements in those groups. If all elements have different names it works as expected:
Intended behavior:
The problem is that I want to plot only 5 algorithms in different groups, and…

Fabio
- 49
- 6
3
votes
1 answer
Removing grid between transparent ggplot plots arranged by ggarrange
I'm trying to produce a figure containing multiple ggplot2 plots arranged by ggarrange from the package ggpubr and annotated on the left side. The ggplot2 plots are transparent or have a transparent background.
The issue arose lately (i.e. I did not…

ahmathelte
- 559
- 3
- 15
3
votes
2 answers
Align multi-figure ggplots with patchwork and single legend
I am using patchwork to create a multi-plot figure in R. They share one legend, so I am including the legend at the top right panel using ggpubr::get_legend() (note: I cannot use patchwork::plot_layout() because the legends have different underlying…

Brigadeiro
- 2,649
- 13
- 30
3
votes
2 answers
Compare boxplot with Wilcoxon test
I am comparing two groups of lengths (different individuals) with boxplots using ggplot2 package in R. I want to compare the two distributions but so far the only way I found to use a wilcoxon test is stat_compare_means from the "ggpubr" package. Is…

FKM
- 31
- 2
- 4