Written and maintained by CASRAI Editorial Board
Published · Last updated
On this page
ggarrange() is a function in the R package ggpubr that places several ggplot2 plots (or arbitrary gtables) into one figure grid, with options for panel labels such as A, B, C, relative panel sizes, axis alignment and a single shared legend. You call it as ggarrange(plot1, plot2, ncol = 2, nrow = 1) after loading ggpubr, and it returns an object that is a ggplot, or a list of ggplots when the arrangement spans several pages.
What ggarrange is used for in research
Journal figures are rarely a single plot. A results figure usually combines a distribution, a group comparison and a model summary, each labelled so the text can refer to “panel B”. ggarrange() builds that composite from plots you have already made, so the figure can be reproduced from a script rather than assembled by hand in a drawing program. That matters for research practice: a scripted figure can be regenerated when data or a reviewer request changes, and the code is part of the record of how the figure was made.
The ggpubr reference page describes two things that set ggarrange() apart from the plain cowplot function it builds on: it can arrange multiple ggplots over multiple pages, and it can create a common legend for several plots. Its source is the ggpubr package, maintained by Alboukadel Kassambara and distributed on CRAN under GPL-2 or GPL-3 (CRAN package page, read 2026-11-14).
It combines with other pieces of the ggplot2 toolchain covered on this site: building ggplots in R, ggplot2 themes for consistent panel styling, and ggrepel for readable point labels inside a panel.
How to install or access it
ggpubr is on CRAN. The package page lists version 1.0.0, published 2026-07-06, which depends on R 4.1.0 or later and ggplot2 3.5.2 or later, and imports cowplot (1.2.0 or later), gridExtra, ggrepel, ggsignif, rstatix and dplyr among others (CRAN, read 2026-11-14). Because cowplot and gridExtra are imports, installing ggpubr installs them too.
install.packages("ggpubr")library(ggpubr)
Loading ggpubr also makes its plotting helpers available (ggboxplot(), ggdotplot(), ggdensity(), annotate_figure() and others), which the examples below use. If your R or ggplot2 is older than the dependency versions above, update them first, or install the older ggpubr release your setup supports.
Step-by-step: combine three plots into one labelled figure
The ggpubr reference example uses R’s built-in ToothGrowth data. The steps below follow it.
- Prepare the data. Convert the grouping variable to a factor so it is treated as categories:
df = ToothGrowth; df$dose = as.factor(df$dose). - Create each plot and store it in an object.
bxp = ggboxplot(df, x = "dose", y = "len", color = "dose", palette = "jco"), thendp = ggdotplot(df, x = "dose", y = "len", color = "dose", palette = "jco"), thendens = ggdensity(df, x = "len", fill = "dose", palette = "jco"). - Arrange them.
ggarrange(bxp, dp, dens, ncol = 2, nrow = 2)fills a 2 x 2 grid, and with three plots one cell stays empty. - Add panel labels.
ggarrange(bxp, dp, dens, ncol = 2, nrow = 2, labels = c("A", "B", "C")), orlabels = "AUTO"for upper-case letters generated for you,labels = "auto"for lower case. - Share a legend.
ggarrange(bxp, dp, common.legend = TRUE)keeps one legend for the figure instead of one per plot. - Set panel sizes.
ggarrange(bxp, dp, ncol = 2, widths = c(2, 1))makes the first column twice as wide as the second.
The same call accepts a list of plots through plotlist, which is handy when plots are produced in a loop: ggarrange(plotlist = my_plots, ncol = 3), where my_plots is a list of ggplot objects.
Arguments that change the layout
The data table below lists the arguments most researchers need, with defaults and effects taken from the ggpubr reference. Three points are worth reading closely.
Labels: position and styling
Labels are placed relative to each subplot. label.x = 0 puts them at the far left and label.y = 1 at the top; hjust = -0.5 and vjust = 1.5 nudge them. A more negative hjust moves a label further right, and a larger positive vjust moves it further down. Style them with font.label = list(size = 14, color = "black", face = "bold"), the documented defaults. Each of these accepts a single value or a vector, so one panel can differ from the others.
Alignment
align takes “none” (default), “h”, “v” or “hv”. Use “h” or “hv” when panels share an x axis and their plotting areas should line up despite different axis-label widths.
Legends
legend sets the position (“top”, “bottom”, “left”, “right”) or removes it (“none”). common.legend = TRUE creates one shared legend. The reference states that this takes the legend of the first plot and drops the others, which is only accurate when all plots share the same scale; the function does not reconcile differing scales. A plot index or vector can select which plot supplies the legend, and legend.grob accepts a legend built separately, for example with get_legend(). Check the figure against your data: if two panels colour the same groups differently, a common legend will mislead.
Add “Figure 1” and titles with annotate_figure()
ggarrange() does not add an overall caption or figure number. ggpubr’s annotate_figure() does. It works on a single ggplot or on the output of ggarrange(), grid.arrange() or plot_grid(), and its arguments include top, bottom, left, right, fig.lab, fig.lab.pos, fig.lab.size, fig.lab.face, column.titles and row.titles (ggpubr reference, read 2026-11-14).
fig = ggarrange(bxp, dp, dens, ncol = 2, nrow = 2, labels = "AUTO")annotate_figure(fig, top = "Tooth length by dose", fig.lab = "Figure 1")
fig.lab.pos defaults to “top.left”, with “top”, “top.right”, “bottom.left”, “bottom” and “bottom.right” as alternatives; fig.lab.face accepts plain, bold, italic or bold.italic. Text can be a character string or a grob made with text_grob(). The reference notes that column.titles and row.titles assume equal-sized columns and rows, which is the ggarrange() default, so do not combine them with unequal widths or heights.
Output and how to read it
The return value is an object of class ggarrange: a single ggplot, or a list of ggplots when the plots do not fit on one page. In an interactive session a single-page result draws in the plot pane. Check the following before using the figure.
- Every panel carries its own scale. ggarrange() places plots; it does not harmonise their axes. Compare panels only where you set matching limits.
- Empty cells are expected when the number of plots is smaller than ncol x nrow, as in the three-plot 2 x 2 example.
- Label order follows plot order and the fill direction. Panels fill row by row by default. The current datanovia reference lists a
byrowargument that fills by column when FALSE (passed through to plot_grid()), and aspacingargument for the margin around each plot in text-line units (default 0).
Troubleshooting
Error: could not find function “ggarrange”
The function lives in ggpubr, so it needs library(ggpubr) in the session. If that line fails, the package is not installed or not available for your R version; compare your R and ggplot2 versions with the dependency versions in the install section.
Error: unused argument (byrow or spacing)
The CRAN-hosted reference for ggpubr 0.6.0 does not list byrow or spacing, while the current reference does. An unused-argument error usually means an older installed version; update ggpubr from CRAN.
The shared legend does not match one of the panels
That is the documented limitation of common.legend = TRUE: it uses one plot’s legend. Give all plots the same scale and palette, pick the plot that supplies the legend by index, or turn the shared legend off and keep each panel’s own with legend = "right" or similar.
Panel labels overlap the plot area
Adjust hjust, vjust, label.x and label.y, remembering that a larger positive vjust moves a label down and a more negative hjust moves it right.
Axes do not line up between panels
Set align = "hv" (or “h” or “v”). If the panels are faceted, the cowplot documentation says plot_grid() needs its axis argument specified when aligning complex plots such as faceted ones; ggarrange() passes its arguments to plot_grid(), so consider building that panel arrangement with cowplot directly if alignment still fails.
Free alternatives to ggarrange
All options below are free R packages. The table lists only what the cited documentation states.
| Tool | How plots are combined | Source facts |
|---|---|---|
| ggpubr::ggarrange() | Function call with ncol, nrow, labels, widths, common.legend | Can span multiple pages and create a common legend (ggpubr reference) |
| cowplot::plot_grid() | Function call with rel_widths, rel_heights, labels, align, axis | Described as “Arrange multiple plots into a grid” (cowplot reference); see the site’s cowplot guide |
| patchwork | Operators: p1 + p2 adds plots; (p1 | p2 | p3) / p4 sets rows and columns |
MIT licence; goal is to make combining ggplots “ridiculously simple” (patchwork site); see the site’s patchwork guide |
| gridExtra::grid.arrange() | Function call returning a grid object | Its output can be passed to annotate_figure() (ggpubr reference); gridExtra is imported by ggpubr (CRAN) |
Choose by workflow rather than by feature count. If you already use ggpubr’s plotting helpers or need a shared legend and a “Figure 1” label in one package, ggarrange() plus annotate_figure() covers both. If you prefer composing figures with operators, patchwork’s syntax is shorter. If you need fine control over axis alignment, cowplot exposes the axis argument directly.
Frequently asked questions
What does ggarrange do in R?
It arranges several ggplot2 plots or gtables into a single grid figure, with optional panel labels, relative widths and heights, alignment and a shared legend. It belongs to the ggpubr package.
How do I add A, B, C labels with ggarrange?
Pass labels = c("A", "B", "C"), or labels = "AUTO" for upper-case letters and "auto" for lower-case. Position them with label.x, label.y, hjust and vjust.
How do I use one legend for all plots?
Set common.legend = TRUE and, if needed, legend = "bottom". The shared legend comes from the first plot unless you select another, so it is only accurate when all plots share the same scale.
How do I make one panel wider than another?
Use widths for columns and heights for rows. They are relative: widths = c(2, 1) makes the first column twice as wide as the second.
How do I add a figure number or title to the combined figure?
Wrap the result in annotate_figure() and set fig.lab = "Figure 1" and top for a title.
What is the difference between ggarrange and plot_grid?
plot_grid() is the cowplot function ggarrange() builds on. According to the ggpubr reference, ggarrange() additionally arranges plots over multiple pages and can create a common legend.
Sources
- ggpubr reference, ggarrange(): rpkgs.datanovia.com/ggpubr/reference/ggarrange.html and the CRAN-hosted reference search.r-project.org/CRAN/refmans/ggpubr/html/ggarrange.html (read 2026-11-14).
- ggpubr reference, annotate_figure(): rpkgs.datanovia.com/ggpubr/reference/annotate_figure.html (read 2026-11-14).
- CRAN package page for ggpubr: cran.r-project.org/web/packages/ggpubr/index.html (read 2026-11-14).
- cowplot reference, plot_grid(): wilkelab.org/cowplot/reference/plot_grid.html (read 2026-11-14).
- patchwork documentation: patchwork.data-imaginist.com (read 2026-11-14).
Data: ggpubr ggarrange() arguments: defaults and effects
Compilation of the main ggarrange() arguments from the ggpubr reference documentation, giving each argument's documented default and its effect on the combined figure layout.
| Argument | Default | Effect |
|---|---|---|
| ncol / nrow | NULL | Number of columns or rows in the grid |
| labels | NULL | Panel labels; "AUTO" gives upper-case, "auto" lower-case |
| label.x / label.y | 0 / 1 | Label position relative to each subplot (far left, top) |
| hjust / vjust | -0.5 / 1.5 | More negative hjust moves labels right; larger vjust moves them down |
| font.label | list(size = 14, color = "black", face = "bold", family = NULL) | Label styling |
| align | none | Align panels horizontally (h), vertically (v), both (hv) or not at all |
| widths / heights | 1 | Relative column widths and row heights, e.g. c(2, 1) |
| legend | NULL | Legend position: top, bottom, left, right or none |
| common.legend | FALSE | TRUE creates one shared legend from the first plot unless another is selected; accurate only if plots share the same scale |
| legend.grob | NULL | Legend grob, for example from get_legend(), used as the common legend |
| byrow | TRUE | Fill panels by row; FALSE fills by column (listed in the current datanovia reference) |
| spacing | 0 | Margin around each plot in text-line units (listed in the current datanovia reference) |
Sources
- ggpubr reference: ggarrange (accessed 2026-11-14)
- CRAN reference manual page: ggarrange (ggpubr 0.6.0) (accessed 2026-11-14)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







