An R package to prepare publication ready plots based on the ggplot2 plotting system.
Questions tagged [ggpubr]
532 questions
3
votes
0 answers
Include multiple figures with knitr::include_graphics() in a single chunk an each figure with its own label (A, B, C, ...)
I would like to include several jpg/png figures side by side and each labeled by a letter (A, B, C, ...) in a Rmarkdown report compiled to both PDF and HTML.
Including the figures side by side is easy with knitr::include_graphics() and setting…

mavericks
- 1,005
- 17
- 42
3
votes
0 answers
Combining stat_pvalue_manual with fill = GROUP
Hello I am trying to use stat_pvalue_manual from the ggpubr package to show the output of some emmeans and Tukey's post hoc tests on my graphs. I have used stat_pvalue_manual successfully in the past, but never with a fill = GROUP attribute. This…

Hannah Harder
- 67
- 10
3
votes
2 answers
Variable geom_text is overwritten when plots saved in list
I am trying to organize several dozens of plots using ggarrange, so I have setup a loop in which I save each plot in a list. Each plot differs from each other with different data, title, etc. Everything works perfectly until I try to use geom_text…

Herman Toothrot
- 1,463
- 3
- 23
- 53
3
votes
2 answers
Plot pvalue information for mean comparisons by grouping variable
I've put together a plot to view groups separately but now want to include significance levels for mean pairwise comparison in the plot. While I can do the comparison outside of the plot I'm wondering what the most efficient way of including the…

NColl
- 757
- 5
- 19
3
votes
1 answer
Add statistically significant difference between bars to plotnine plot (ggpubr equivalent)
In many plots one wants to highlight the statistical significance of an observed difference between some results. This task can be done in R using the ggpubr() or the geom.signif() extension.
An example of what I mean is here (see horizontal bars…

schmat_90
- 572
- 3
- 22
3
votes
1 answer
Manually plotting significance relations between sub-groups on ggplot2 barplot
I've been trying to plot manually labelled significance bars for a subset of groups on a ggplot2 barplot using ggsignif or ggpubr without much luck. The data is something like the following MWE:
set.seed(3)
## create data
df <- data.frame(activity =…

drgibbon
- 405
- 1
- 4
- 11
3
votes
2 answers
R - stat_compare_means return differnt value from Kruskal-Wallis test
I want to plot the p value of Kruskal-Wallis test to my ggplot using the R function stat_compare_means from the package ggpubr.
However, the plotted value is different from the value if I simply run the function:
kruskal.test(value ~ type, data =…

DigiPath
- 179
- 2
- 10
3
votes
1 answer
How to adjust margin in ggarrange ggpubr ggplot (axis elements disappear) R
I want to stack 3 plots into 1 using ggarrange but the x-axis elements (dates) of the bottom plot are always disappeared.
For example, here axis elements of plot_3 (Z) are missing.
ggarrange(plot_1, plot_2, plot_3 + rremove("x.text"),
…

dss333
- 71
- 1
- 2
- 7
3
votes
1 answer
Missing legend items when using common.legend in ggarrange with ggplot2
Given a setup like:
require(ggplot2)
require(ggpubr)
size = 20
s = 0.2
d = seq(0,2*pi, length.out=size)
df = data.frame(
d=d + runif(size)*s,
a=sin(d) + runif(size)*s,
b=sin(d-10) + runif(size)*s,
c=cos(2*d) + runif(size)*s
)
when trying…

rovyko
- 4,068
- 5
- 32
- 44
3
votes
2 answers
R ggpubr: move legend title above the legend keys
I am struggling with the legend position within ggpubr. I know that I can modify the legend position p.e. by ggpar(legend = "bottom"). But, how to place legend title above the legend keys?
In ggplot2, it seems that guide_legend(title.position =…

maycca
- 3,848
- 5
- 36
- 67
3
votes
1 answer
ggpubr: Show significance levels (*** or n.s.) instead of p-value in the label
I would like to show the significance levels (*** or n.s.) as labels in my linear regression using ggpubr in R. This seems to be done by using aes(label = ..p.signif..) as posted here:…

maycca
- 3,848
- 5
- 36
- 67
3
votes
1 answer
ggplot / ggpubr: annotate_figure ignored when exporting plot
I am trying to annotate a grid of plot that I arranged using ggarrange() from the ggpubr package. To do so, I use the annotate_figure() function after the plot was generated.
My problem: when doing it interactively (i.e. not creating files with my…

Galapagoose
- 31
- 1
- 2
3
votes
2 answers
Error bars in ggpubr/ggbarplot suddenly merged (no code change), how can I separate them again?
I have the following code:
ggbarplot(Text1, x = "Page", y = "IA_REGRESSION_OUT_COUNT",
color = "Modified", add = "mean_se", fill = "Modified",
width = .6, position = position_dodge(0.8)) +
stat_compare_means(method =…

Grig
- 109
- 1
- 10
3
votes
1 answer
Display Spearman correlations between pairs of boxplots in ggplot2/ggpubr
I have a plot with three boxplots and I need to display Spearman correlations between pairs of boxplots using ggplot2 or ggpubr.
It is easy to make a similar plot, but with pairwise p-values. For example,
library(ggpubr)
data("ToothGrowth")
df <-…

Hrant
- 219
- 3
- 12
3
votes
2 answers
coloring by a group using ggscatter in R
I am using ggscatter function from ggpubr library to make a scatter plot.
My data frame looks like this
1 a b chr17 + 0.003 0.005 0,2 282232 4,0 253259 non_sig
10 a b chr22 - 0.733 0.6855 16,17 3,3 24,45 11,4 …

user3138373
- 519
- 1
- 6
- 18