Scale.color_discrete_manual

Scale.color_discrete_manual

Create a discrete color scale to be used for the plot.

Arguments

Aesthetics Acted On

color

Examples

plot(x=rand(12), y=rand(12), color=repeat(["a","b","c"], outer=[4]),
     Scale.color_discrete_manual("red","purple","green"))
x 0.00 0.25 0.50 0.75 1.00 a b c Color 0.0 0.5 1.0 y
D = by(dataset("datasets","HairEyeColor"), [:Eye,:Sex], d->sum(d[:Freq]))
 rename!(D, :x1, :Frequency)
# Is there a hazel color?
palette = ["blue","brown","green","tan"]

pa= plot(D, x=:Sex, y=:Frequency, color=:Eye, Geom.bar(position=:stack),
    Scale.color_discrete_manual(palette...)
)
pb= plot(D, x=:Sex, y=:Frequency, color=:Eye, Geom.bar(position=:stack),
    Scale.color_discrete_manual(palette[4:-1:1]..., order=[4,3,2,1])
)
hstack(pa, pb)
Sex Male Female Green Hazel Blue Brown Eye 0 100 200 300 400 Frequency Sex Male Female Brown Blue Hazel Green Eye 0 100 200 300 400 Frequency