Skip to content

Axis labels

Use these functions with the labels argument to ggplot2 scales to control the formatting of axis labels and legend keys.

label_bytes()
Label bytes (1 kB, 2 MB, etc)
label_currency()
Label currencies ($100, €2.50, etc)
label_date() label_date_short() label_time() label_timespan()
Label date/times
label_log()
Label numbers in log format (10^3, 10^6, etc)
label_number() label_comma()
Label numbers in decimal format (e.g. 0.12, 1,234)
label_number_auto()
Label numbers, avoiding scientific notation where possible
label_ordinal() ordinal_english() ordinal_french() ordinal_spanish()
Label ordinal numbers (1st, 2nd, 3rd, etc)
label_parse() label_math()
Label with mathematical annotations
label_percent()
Label percentages (2.5%, 50%, etc)
label_pvalue()
Label p-values (e.g. <0.001, 0.25, p >= 0.99)
label_scientific()
Label numbers with scientific notation (e.g. 1e05, 1.5e-02)
label_wrap()
Label strings by wrapping across multiple lines

Axis breaks

Use these functions with the breaks argument to ggplot2 scales to control the position of axis breaks and values of legend keys.

breaks_extended()
Automatic breaks for numeric axes
breaks_log()
Breaks for log axes
breaks_pretty()
Pretty breaks for date/times
breaks_timespan()
Breaks for timespan data
breaks_width()
Equally spaced breaks
minor_breaks_width() minor_breaks_n()
Minor breaks

Bounds: ranges & rescaling

Functions for rescaling data and adjusting scale ranges.

rescale()
Rescale continuous vector to have specified minimum and maximum
rescale_max()
Rescale numeric vector to have specified maximum
rescale_mid()
Rescale vector to have specified minimum, midpoint, and maximum
rescale_none()
Don't perform rescaling
pal_rescale() rescale_pal()
Rescale palette (continuous)
expand_range()
Expand a range with a multiplicative or additive constant
zero_range()
Determine if range of vector is close to zero, with a specified tolerance
oob_censor() oob_censor_any() oob_discard() oob_squish() oob_squish_any() oob_squish_infinite() oob_keep() censor() discard() squish() squish_infinite()
Out of bounds handling

Transformations

Functions to describe common and custom scale transformations their inverses, and ways of generating breaks and labels.

transform_asinh() asinh_trans()
Inverse Hyperbolic Sine transformation
transform_asn() asn_trans()
Arc-sin square root transformation
transform_atanh() atanh_trans()
Arc-tangent transformation
transform_boxcox() boxcox_trans() transform_modulus() modulus_trans()
Box-Cox & modulus transformations
transform_compose() compose_trans()
Compose two or more transformations together
transform_date() date_trans()
Transformation for dates (class Date)
transform_exp() exp_trans()
Exponential transformation (inverse of log transformation)
transform_identity() identity_trans()
Identity transformation (do nothing)
transform_log() transform_log10() transform_log2() transform_log1p() log_trans() log10_trans() log2_trans() log1p_trans() transform_pseudo_log() pseudo_log_trans()
Log transformations
transform_probability() transform_logit() transform_probit() probability_trans() logit_trans() probit_trans()
Probability transformation
transform_reciprocal() reciprocal_trans()
Reciprocal transformation
transform_reverse() reverse_trans()
Reverse transformation
transform_sqrt() sqrt_trans()
Square-root transformation
transform_time() time_trans()
Transformation for date-times (class POSIXt)
transform_timespan() timespan_trans() transform_hms() hms_trans()
Transformation for times (class hms)
transform_yj() yj_trans()
Yeo-Johnson transformation

Colour palettes & colour mapping

Functions for specifying colour palettes, colour mapping, and various helper functions.

pal_brewer() brewer_pal()
Colour Brewer palette (discrete)
pal_dichromat() dichromat_pal()
Dichromat (colour-blind) palette (discrete)
pal_div_gradient() div_gradient_pal()
Diverging colour gradient (continuous).
pal_gradient_n() gradient_n_pal()
Arbitrary colour gradient palette (continuous)
pal_grey() grey_pal()
Grey scale palette (discrete)
pal_hue() hue_pal()
Hue palette (discrete)
pal_seq_gradient() seq_gradient_pal()
Sequential colour gradient palette (continuous)
pal_rescale() rescale_pal()
Rescale palette (continuous)
pal_viridis() viridis_pal()
Viridis palette
col2hcl()
Modify standard R colour in hcl colour space.
col_numeric() col_bin() col_quantile() col_factor()
Colour mapping
colour_ramp()
Fast colour interpolation
muted()
Mute standard colour
alpha()
Modify colour transparency

Non-colour palette functions

Functions to help scale non-colour aesthetics.

pal_area() area_pal() abs_area()
Area palettes (continuous)
pal_identity() identity_pal()
Identity palette
pal_linetype() linetype_pal()
Line type palette (discrete)
pal_manual() manual_pal()
Manual palette (discrete)
pal_rescale() rescale_pal()
Rescale palette (continuous)
pal_shape() shape_pal()
Shape palette (discrete)

Creating your own scales and mutable ranges

Scales control the details of how data values are translated to visual properties. The following functions help users create (and update) custom scales: pulling together palettes, bounding functions and transformations to provide a complete pathway from raw data to perceptual properties.

cscale()
Continuous scale
dscale()
Discrete scale
train_continuous()
Train (update) a continuous scale
train_discrete()
Train (update) a discrete scale
Range DiscreteRange ContinuousRange
Mutable ranges