Fitted-Model-Based Annotations :: Cheat Sheet

‘ggpmisc’ 0.6.3

Pedro J. Aphalo

2025-11-29

Basics

ggpmisc is based on the grammar of graphics implemented in ggplot2, the idea that you can build every graph from the same components: a data set, a coordinate system, and geoms—visual marks that represent data points. If you are not already familiar with this grammar and ggplot2 you should visit the ggplot2 Cheat Sheet first, and afterwards come back to this Cheat Sheet.

Differently to ggplot2, no geometries with the new stats as default are provided. The plot layers described here are always added with a stat, and when necessary, their default geom argument can be overridden. The default geoms for the statistics described below are from packages ggplot2 and ggpp.

library(ggpmisc)

Most of the layer functions in ggpmisc aim at making it easier to add to plots information derived from model fitting, tests of significance and some summaries. All layer functions work as expected with groups and facets.

Correlation

Fitted models

The statistics for fitted models come in matched pairs, one that adds a plot layer with one or more curves and confidence band(s), and one that annotates the plot with the fitted model equation and/or other parameter estimates. These depend on the type of fitted model and include \(R^2\), \(F\), \(P\), \(AIC\), \(BIC\), and \(n\). The curve plotting stats are similar to ggplot2::stat_smooth() but the ones for textual annotations have no equivalent in ‘ggplot2’.

ANOVA or summary tables

Multiple comparisons

Peaks and valleys

Volcano and quadrant plots

These plots are frequently used with gene expression data, and each of the many genes labelled based on the ternary outcome from a statistical test. Data are usually, in addition transformed. ‘ggpmisc’ provides several variations on continuous, colour, fill and shape scales, with defaults set as needed. Scales support log fold-change (logFC), false discovery ratio (FDR), P-value (Pvalue) and binary or ternary test outcomes (outcome).

Utility functions

Most of the functions used to generate formatted labels in layers and scales are also exported.


Learn more at docs.r4photobiology.info/ggpmisc/.