
Continuous ggplot2 Gradients from a biopalette Palette
Source:R/scale.R
scale_color_biopalette_gradient.RdBuild a continuous colour or fill gradient from a sequential or diverging
biopalette palette. The complete palette supplies the gradient stops to
ggplot2::scale_colour_gradientn() or ggplot2::scale_fill_gradientn().
Gradients are interpolated in Lab colour space, the same space used when
get_palette() resamples sequential and diverging palettes.
Usage
scale_color_biopalette_gradient(
palette,
...,
type = NULL,
reverse = FALSE,
values = NULL,
midpoint = NULL,
transform = "identity",
palettes_dir = NULL
)
scale_colour_biopalette_gradient(
palette,
...,
type = NULL,
reverse = FALSE,
values = NULL,
midpoint = NULL,
transform = "identity",
palettes_dir = NULL
)
scale_fill_biopalette_gradient(
palette,
...,
type = NULL,
reverse = FALSE,
values = NULL,
midpoint = NULL,
transform = "identity",
palettes_dir = NULL
)Arguments
- palette
Character. Name of the palette.
- ...
Passed to
ggplot2::scale_colour_gradientn()orggplot2::scale_fill_gradientn(), for examplename,breaks,labels,limits,transform,na.value, andguide.- type
Character.
"sequential"or"diverging". IfNULL, the type is detected automatically.- reverse
Logical. Reverse the palette. When
valuesis supplied, its spacing is reversed with the colours. Default:FALSE.- values
Optional numeric positions for the palette colours, as accepted by
ggplot2::scale_colour_gradientn(). Must have one value per palette colour, be non-decreasing, and lie in[0, 1].- midpoint
Optional finite numeric value to place at the visual centre of a diverging palette. Values are rescaled with equal units on either side of this point, so the shorter side of an asymmetric data range does not reach the palette's extreme colour.
midpointcannot be combined withvaluesor a customrescaler. The default,NULL, applies ordinary range-based scaling.- transform
A transformation specification accepted by
ggplot2::continuous_scale(). The same transformation is applied tomidpointbefore the gradient is rescaled, so the centre remains correct under transformations such as"log10". Default:"identity".- palettes_dir
Character. Directory holding a palette collection. If
NULL, the palettes bundled with the package are used.
Details
Qualitative palettes are rejected because interpolating unordered category
colours does not produce a meaningful continuous scale. Use
scale_color_biopalette() or scale_fill_biopalette() for those palettes.

