An R package to prepare publication ready plots based on the ggplot2 plotting system.
Questions tagged [ggpubr]
532 questions
6
votes
2 answers
ggplot2: axis does not show all ticks/breaks
I am currently plotting data using the ggpubr package in R (based on ggplot2). When I plot the means of two conditions including standard errors, the y-axis should be limited from 1 to 7, which I indicate using:
p <- ggline(data, x = "condition", y…

statleo
- 81
- 1
- 7
6
votes
2 answers
Draw a "grid" between arranged plots
I'm working with 4 different plots and I'm using ggarrange() from the ggpubr-package to put them in a single plot. I've prepared an example:
library(ggpubr)
library(ggplot2)
p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()…

f.lechleitner
- 3,554
- 1
- 17
- 35
6
votes
3 answers
ggarrange with common legend produces extra blank plot in markdown
I am using R Notebooks and have a chunk with some code for arranged histograms. When I use a common legend it produces an extra empty plot, which looks terrible in the rendered html file. This phenomenon disappears without a shared legend, but the…

BKV
- 223
- 3
- 4
6
votes
1 answer
R ggplot2 boxplots - ggpubr stat_compare_means not working properly
I am trying to add significance levels to my boxplots in the form of asterisks using ggplot2 and the ggpubr package, but I have many comparisons and I only want to show the significant ones.
I try to use the option hide.ns=TRUE in…

DaniCee
- 2,397
- 6
- 36
- 59
5
votes
1 answer
add one legend with all variables for combined graphs
I'm trying to plot two graphs side-by-side with one common legend that incorporates all the variables between both graphs (some vars are different between the graphs).
Here's a mock example of what I've been attempting:
#make relative abundance…

kas
- 285
- 1
- 8
5
votes
3 answers
Problems with positioning of ggplot labels with ggarrange
I'm trying to create a panel of plots using ggarrange. I'm using the "labels" argument to create a title for each one, but the positioning is coming out differently for each plot depending on how long the title is. It seems that the longer the…

LvG
- 417
- 1
- 4
- 11
5
votes
1 answer
Font size of labels and values in a ggarranged plot
I made 4 barplots in ggplot: o, p, q, r.
I put them together in a single plot using the ggpubr package and the following code:
library(ggpubr)
figure = ggarrange(o + font("y.text", size = 5), p +
font("y.text", size = 5), q + font("y.text", size =…

Ivan A. Ramírez Zapata
- 157
- 1
- 9
5
votes
0 answers
ggpubr::ggarrange save plots over multiple pages with one legend per page
I'm trying to save plots over multiple pdf plots with one overall legend per page. I'm wondering is there a neat way to use ggsave and ggpubr::ggarrange to do this? Changing nrow ncol within ggarrange only changes the setup for one page and forces…

user63230
- 4,095
- 21
- 43
5
votes
0 answers
ERROR: Only strings can be converted to symbols
I'm not that well versed in R but have recently installed the ggpubr package as want to make a paired box plot. I've tried been using:
ggpaired(question1, cond1 = question1$q1, cond2 = question1$q2,
fill = "condition", palette = "jco")
and I…

Amber Jaffrey
- 51
- 1
- 2
5
votes
2 answers
Change point denoting mean in ggerrorplot to a line
I would like to change the point denoting the mean in ggerrorplot to a horizontal line (similar to the line used to denote a median in a boxplot). I would like this line to be slightly thicker than the error bars.
I do not see an option to do so in…

Ann Marie Weideman
- 55
- 4
5
votes
1 answer
How to show whiskers and points on violin plots?
I have a dataframe df with the following data. I want to plot the logCPM expression of the gene between two groups A and B.
Samples Type GeneA
Sample1 B 14.82995162
Sample2 B 12.90512275
Sample3 B 9.196524783
Sample4 A …

beginner
- 1,059
- 8
- 23
5
votes
2 answers
Add ticks in-between discrete groups on x-axis
I want to replace one of my grouped boxplots (below) to before-after kind, but keep it grouped. This one was made using ggboxplot() from ggpubr. I know there's also ggpaired() but I couldn't manage to make it grouped like this one.
Thanks to this…

Venca
- 93
- 1
- 9
5
votes
1 answer
How do i create graphs and images to show on the same panel in R
I'm new to R and trying to show graphs and images on the same page with R.
I tried to use library(ggpubr) and ggarrange() function.
to import the images I used library(png) and readPNG() to import my images.
The end result i'm aiming for is…

Eviatar Nov Weizman
- 85
- 1
- 6
5
votes
0 answers
Legend is displaying additional shape
I'm using the following data frame:
df1 <- structure(list(Genotype = structure(c(1L, 1L, 1L, 1L, 1L,
2L,2L,2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
1L,1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L),
.Label=…

John Gagnon
- 825
- 1
- 8
- 20
4
votes
1 answer
stat_compare_means() for multiple groups in faceted ggplot data
Hi I have a sample df as follows and I'm trying to perform t tests using the ggpubr package with the stat_compare_means() function however I cannot get it to compare across the groups that I want:
set.seed(13)
df = data.frame(grouping =…

Jeff238
- 396
- 2
- 15