Function index
ColorSchemes.ColorSchemeBase.:*Base.getBase.getBase.reverseColorSchemes.findcolorschemeColorSchemes.findcolorschemeColorSchemes.getinverseColorSchemes.getinverseColorSchemes.loadallschemesColorSchemes.loadcolorschemeColorSchemes.resampleColorSchemes.resample
Base.get — Method
get(cs::ColorScheme, g::Color{T,1} where T<:Union{Bool, AbstractFloat, FixedPoint})Return the color in cs that corresponds to the gray value g.
Base.get — Method
get(cscheme::ColorScheme, inData :: Array{Number, 2}, rangescale=:clamp)
get(cscheme::ColorScheme, inData :: Array{Number, 2}, rangescale=(minVal, maxVal))Return an RGB array of colors generated by applying the colorscheme to the 2D input data.
If rangescale is :clamp the colorscheme is applied to values between 0.0-1.0, and values outside this range get clamped to the ends of the colorscheme.
If rangescale is :extrema, the colorscheme is applied to the range minimum(indata)..maximum(indata).
Else, if rangescale is :centered, the colorscheme is applied to the range -maximum(abs, indata)..maximum(abs, indata).
TODO: this function expects the colorscheme to consist of RGB [0.0-1.0] values. It should work with more colortypes.
Examples
img = get(colorschemes[:leonardo], rand(10,10)) # displays in Juno Plots window, butsave("testoutput.png", img) # you'll need FileIO or similar to do thisimg2 = get(colorschemes[:leonardo], 10.0 * rand(10, 10), :extrema)img3 = get(colorschemes[:leonardo], 10.0 * rand(10, 10), (1.0, 9.0))# Also works with PerceptualColourMapsusing PerceptualColourMaps # warning, installs PyPlot, PyCall, LaTeXStringsimg4 = get(PerceptualColourMaps.cmap("R1"), rand(10,10))# resample an existing scheme to make a new oneget(ColorSchemes.darkrainbow, range(0.0, 1.0, length=13)) |> ColorSchemeBase.reverse — Method
reverse(cscheme)Make a new ColorScheme with the same colors as cscheme but in reverse order.
ColorSchemes.findcolorscheme — Method
findcolorscheme(str;
search_notes=true)Find all colorschemes matching str. str is interpreted as a regular expression (case-insensitive).
This returns an array of symbols which are the names of matching schemes in the colorschemes dictionary.
julia> findcolorscheme("ice")colorschemes containing "ice" seaborn_icefire_gradient seaborn_icefire_gradient (notes) sequential, ice fire gradient... ice flag_is (notes) The flag of Iceland... botticelli botticelli (notes) palette from artist Sandro Bot... ...found 6 results for "ice"To read the notes of a built-in colorscheme cscheme:
colorschemes[:cscheme].notesColorSchemes.getinverse — Function
getinverse(cscheme::ColorScheme, c, range=(0.0, 1.0))Computes where the provided Color c would fit in cscheme.
This is the inverse of get() — it returns the value x in the provided range for which get(scheme, x) would most closely match the provided Color c.
Examples
The first example asks: "where in the leonardo colorscheme will I find the nearest color to red?":
julia> getinverse(colorschemes[:leonardo], RGB(1, 0, 0))0.6248997995654847julia> getinverse(ColorScheme([Colors.RGB(0,0,0), Colors.RGB(1,1,1)]), Colors.RGB(.5,.5,.5))0.5432555858022048julia> cs = ColorScheme(range(Colors.RGB(0,0,0), stop=Colors.RGB(1,1,1), length=5))julia> getinverse(cs, cs[3])0.5ColorSchemes.loadallschemes — Method
loadallschemes()Load all colorschemes from data files. Not exported.
ColorSchemes.loadcolorscheme — Function
loadcolorscheme(vname, colors, cat="", notes="")Define a ColorScheme from a symbol and an array of colors, and add it to the colorschemes dictionary. Optionally specify a category and some notes.
Example
This is an example (from ColorsSchemes/data/flags.jl) of how the supplied colorschemes are loaded into the ColorSchemes dictionary.
loadcolorscheme(:flag_nu, [ RGB(0.7843137254901961, 0.06274509803921569, 0.1803921568627451), RGB(0.00392156862745098, 0.12941176470588237, 0.4117647058823529), RGB(1.0, 1.0, 1.0), RGB(0.996078431372549, 0.8666666666666667, 0.0), ], "flags", "The flag of Niue")ColorSchemes.resample — Function
resample(cs::colorscheme, n=10)Create a new colorscheme that samples an existing colorscheme cs at n positions, including 0 and 1.
resample(ColorSchemes.leonardo, 10)ColorScheme{Vector{RGB{Float64}}, String, String}( RGB{Float64}[ RGB(0.05482025926320272, 0.016508952654741622, 0.019315160361063788), RGB(0.3097689451431823, 0.15249301022575068, 0.06809921145717472), RGB(0.5217774204862555, 0.4520916788504707, 0.18791801451894713), RGB(0.9724409077178674, 0.7907008712807734, 0.2851364857083522)], "general", "color palette from artist Leonardo Da Vinci's Mona Lisa resampled × 4")ColorSchemes.resample — Method
resample(cs::colorscheme, n, alphafunction)Create a new colorscheme with RGBA colors that samples an existing colorscheme cs n times and applies the single argument alphafunction at each sampling point to set the alpha opacity value.
# set all 20 colors in scheme to alpha 0.5resample(ColorSchemes.turbo, 20, (α) -> 0.5)# set first 10 of 20 colors in scheme to alpha = 1resample(ColorSchemes.turbo, 20, (alpha) -> alpha > 0.5 ? 1 : 0.0)# set alpha value to sine; values around 0.5 are opaque resample(ColorSchemes.leonardo, 10, (alpha) -> sin(alpha * π))ColorSchemes.ColorScheme — Type
ColorScheme(colors, category, notes)Create a ColorScheme from an array of colors. You can also name it, assign a category to it, and add notes.
myscheme = ColorScheme([Colors.RGB(0.0, 0.0, 0.0), Colors.RGB(1.0, 1.0, 1.0)], "custom", "twotone, black and white")