Learn R Programming

ggdist (version 3.3.2)

ramp_colours: Apply partial colour ramps

Description

Given vectors of colours and partial_colour_ramps, ramps the colours according to the parameters of the partial colour ramps, returning a vector of the same length as the inputs giving the transformed (ramped) colours.

Usage

ramp_colours(colour, ramp)

Value

A character vector of colours.

Arguments

colour

character vector of colours.

ramp

a partial_colour_ramp vector.

Author

Matthew Kay

Details

Takes vectors of colours and partial_colour_ramps and produces colours by interpolating between each from colour and the target colour the specified amount (where amount and from are the corresponding fields of the ramp).

For example, to add support for the fill_ramp aesthetic to a geometry, this line could be used inside the draw_group() or draw_panel() method of a geom:

data$fill = ramp_colours(data$fill, data$fill_ramp)

See Also

Other colour ramp functions: guide_rampbar(), partial_colour_ramp(), scale_colour_ramp

Examples

Run this code
pcr = partial_colour_ramp(c(0, 0.25, 0.75, 1), "red")
pcr

ramp_colours("blue", pcr)

Run the code above in your browser using DataLab