Scale.color_continuous

Create a continuous color scale that the plot will use.

This can also be set as the continuous_color_scheme in a Theme

Arguments

Variations

color_continuous_gradient is an alias for Scale.color_continuous.

A number of transformed continuous scales are provided.

Aesthetics Acted On

color

Examples

# The data are all between 0 and 1, but the color scale goes from -1 to 1.
# For example, you might do this to force a consistent color scale between plots.
plot(x=rand(12), y=rand(12), color=rand(12),
     Scale.color_continuous(minvalue=-1, maxvalue=1))
x 0.00 0.25 0.50 0.75 1.00 0.0 -1.0 -0.5 0.5 1.0 Color 0.0 0.5 1.0 y

Define a custom color scale for a grid:

using Colors
x = repeat(collect(1:10), inner=[10])
y = repeat(collect(1:10), outer=[10])
plot(x=x, y=y, color=x+y, Geom.rectbin,
     Scale.color_continuous(colormap=p->RGB(0,p,0)))
x 0 5 10 15 1 5 20 10 15 Color 0 5 10 15 y

Or we can use lab_gradient to construct a color gradient between 2 or more colors:

plot(x=x, y=y, color=x+y, Geom.rectbin,
     Scale.color_continuous(colormap=Scale.lab_gradient(colorant"green",
                                                        colorant"white",
                                                        colorant"red")))
x 0 5 10 15 1 15 20 10 5 Color 0 5 10 15 y

We can also start the color scale somewhere other than the bottom of the data range using minvalue:

plot(x=x, y=y, color=x+y, Geom.rectbin,
     Scale.color_continuous(colormap=p->RGB(0,p,0), minvalue=-20))
x 0 5 10 15 -20 -10 10 20 0 Color 0 5 10 15 y