Skip to contents

Smart axis guides

When a discrete axis carries too many labels, keep only the ones you ask for, draw a leader line back to each tick, and spread the labels over several rows (x axis) or columns (y axis) outside the panel.

guide_axis_smart()
Smart axis labels for ggplot2

Coordinates

Bend an ordinary ggplot into an Archimedean spiral: x runs along the spiral as the angle, y as the radius of the lane, with an angular axis and a radial tick axis, and full facet_wrap() / facet_grid() support.

coord_spiral()
Spiral coordinates for ggplot2
scale_x_spiral_axis() scale_y_spiral_axis()
Fine-tune the axes drawn along a spiral

Cluster trees

Add a hierarchical cluster tree to a discrete x / y axis: the matching scales reorder the categories by dendrogram leaf order so tree and data stay aligned, and faceted plots get one tree per panel attached inside the strip.

guide_axis_cluster() scale_x_cluster() scale_y_cluster()
Cluster axis guide for ggplot2
cluster_order()
Retrieve the dendrogram leaf order
strip_cluster()
Keep cluster trees inside the facet strip

Facets

A facet_grid that frees each panel: scales = “free_x” / “free_y” / “free” are released per panel instead of per column or per row as in facet_grid().

facet_gridn() FacetGridN
A facet_grid() that can free scales panel by panel

Layout algorithms

The three low level placement algorithms used inside the guides: one dimensional anti overlap packing (a port of circlize::smartAlign), box arrangement (a port of ComplexHeatmap::BoxArrange) and multi row stacking on top of them. They can also be called on their own.

smart_align()
One-dimensional label-box de-overlap packing (a smartAlign() port)
box_arrange()
One-dimensional label-box clustering and packing (a BoxArrange port)
smart_stack()
Multi-row label placement engine

Datasets

Real data used by the examples and the vignette: an RNA seq heat map from GEO GSE52778 (a 300 highly variable genes x 8 samples matrix of row z scores) and the marker table and dot plot data from the Seurat PBMC3k tutorial.

airway_heatmap
Processed RNA-seq expression matrix (GEO GSE52778)
pbmc3k_markers
PBMC3k single-cell marker table
pbmc3k_dotplot
PBMC3k dot plot data