# The class returned after interpolation matches the input class.
x <- pal_colour(c("darkslateblue", "cornflowerblue", "slategray1"))
y <- pal_palette(blues = x)
class(pal_ramp(x))
class(pal_ramp(y))
# Choose between linear and spline interpolation.
pal_ramp(x, n = 7, interpolate = "linear")
pal_ramp(x, n = 7, interpolate = "spline")
# Palettes will have the same length after interpolation, regardless of the
# number of colours in the original palette.
z <- pal_palette(
Egypt = c("#DD5129", "#0F7BA2", "#43B284", "#FAB255"),
Java = c("#663171", "#CF3A36", "#EA7428", "#E2998A", "#0C7156")
)
pal_ramp(z, n = 5)
Run the code above in your browser using DataLab