The 'ggplot2' package is excellent and flexible for elegant data visualization in R. However the default generated plots require some formatting before we can send them for publication. Furthermore, to customize a 'ggplot', the syntax is opaque and this raises the level of difficulty for researchers with no advanced R programming skills. 'ggpubr' provides some easy-to-use functions for creating and customizing 'ggplot2'-based publication ready plots. This version includes modern R ecosystem compatibility updates and customizable p-value formatting presets ('APA', 'AMA', 'NEJM', 'Lancet', 'GraphPad', and scientific notation) for publication workflows, plus robust sparse-subset handling in statistical annotation layers such as 'stat_compare_means()' and 'geom_pwc()', with informative per-group skip diagnostics for non-comparable subsets.
P-Value Formatting
ggpubr provides customizable p-value formatting with predefined style presets
to match different journal and publication requirements. Use format_p_value()
for direct formatting, or set p.format.style in statistical functions.
Available styles: "default", "apa", "nejm", "lancet",
"ama", "graphpad", "scientific".
See list_p_format_styles() for details on each style.
Package options
- ggpubr.parse_aes
logical indicating whether to parse aesthetic variable names. Default is
TRUE. For example, if you wantggpubrto handle non-standard column names, likeA-A, without parsing, then set this option toFALSEusingoptions(ggpubr.parse_aes = FALSE).- ggpubr.null_device
A function that creates an appropriate null device. These include:
cowplot::pdf_null_device,cowplot::png_null_device,cowplot::cairo_null_deviceandcowplot::agg_null_device. Default iscowplot::pdf_null_device. This is used in functions likeas_ggplot(), which need to open a graphics device to render ggplot objects into grid graphics objects. This function is used to open a null device to avoid displaying an unnecessary blank page when callingggarrange()oras_ggplot()
Author
Maintainer: Alboukadel Kassambara alboukadel.kassambara@gmail.com
Other contributors:
Laszlo Erdey erdey.laszlo@econ.unideb.hu (Faculty of Economics and Business, University of Debrecen, Hungary) [contributor]