# this code will display all the schemes in a category, as an SVG
# use in this docs/src/catalogue.md file as
# ```@example catalog
# using Luxor, ColorSchemes # hide
# ColorSchemeCategory("cmocean") # hide
# ```
# which displays the "cmocean" category
using Luxor, ColorSchemes
struct ColorSchemeGroup
name::String
end
function generate_scheme_svg(schemename;
swatchwidth = 800,
swatchheight = 20)
# create swatch
cols = colorschemes[schemename].colors
l = length(cols)
Drawing(swatchwidth, swatchheight, :svg)
setline(0.5)
origin()
t = Tiler(swatchwidth, swatchheight, 1, l, margin=0)
for (i, c) in enumerate(cols)
sethue(c)
box(t, i, :fillstroke)
end
finish()
swatch = svgstring()
# fill the template
schemetemplate = """
<div class="schemename">:$(schemename)</div>
<div class="swatch">$(swatch)</div>
"""
return schemetemplate
end
function generate_schemes_in_category(category)
iobuffer = IOBuffer()
write(iobuffer, """
<div class="category">
""")
schemes = filter(s -> occursin(category, colorschemes[s].category), collect(keys(colorschemes)))
for s in sort(schemes)
write(iobuffer, generate_scheme_svg(s))
end
write(iobuffer, """
</div>
""")
return String(take!(iobuffer))
end
function generate_schemes_matching_notes_string(str)
iobuffer = IOBuffer()
write(iobuffer, """
<div class="category">
""")
schemes = filter(s -> occursin(str, colorschemes[s].notes), collect(keys(colorschemes)))
for s in sort(schemes)
write(iobuffer, generate_scheme_svg(s))
end
write(iobuffer, """
</div>
""")
return String(take!(iobuffer))
end
function Base.show(io::IO, m::MIME"text/html", category::ColorSchemeCategory)
print(io, generate_schemes_in_category(category.name))
end
function Base.show(io::IO, m::MIME"text/html", group::ColorSchemeGroup)
print(io, generate_schemes_matching_notes_string(group.name))
end
At the REPL you can search for colorschemes by name:
findcolorscheme("julia")
From "Beautiful colormaps for oceanography": cmocean
using Luxor, ColorSchemes # hide
ColorSchemeCategory("cmocean") # hide
From Scientific colormaps
using Luxor, ColorSchemes # hide
ColorSchemeCategory("scientific") # hide
From matplot
using Luxor, ColorSchemes # hide
ColorSchemeCategory("matplotlib") # hide
From ColorBrewer
using Luxor, ColorSchemes # hide
ColorSchemeCategory("colorbrewer") # hide
From GNUPlot
using Luxor, ColorSchemes # hide
ColorSchemeCategory("gnuplot") # hide
From "collection of perceptually accurate colormaps"
using Luxor, ColorSchemes # hide
ColorSchemeCategory("colorcet") # hide
From "colorschemes used by Seaborn, a Python data visualization library based on matplotlib."
using Luxor, ColorSchemes # hide
ColorSchemeCategory("seaborn") # hide
From "ggthemes tableau palettes"
using Luxor, ColorSchemes # hide
ColorSchemeCategory("tableau") # hide
Colorschemes designed with color-vision deficient users in mind, by authors such as Paul Tol, Masataka Okabe, Kei Ito, and Martin Krzywinski. This list also includes schemes with "cvd" in the Notes field.
using Luxor, ColorSchemes # hide
ColorSchemeCategory("cvd") # hide
ColorSchemeGroup("cvd") # hide
Colors extracted from flags of different countries and regions, downloaded from Flagpedia. Intended to represent these regions in visualizations, but not necessarily effective. Many flags have similar colorschemes. The flags are named according to the region's ISO3166 two-letter abbreviation (often the same as top-level WWW domain), with any hyphens removed.
using Luxor, ColorSchemes # hide
ColorSchemeCategory("flags") # hide
Palettes inspired by works at the Metropolitan Museum of Art in New York. See Blake Mills' github repository.
using Luxor, ColorSchemes # hide
ColorSchemeCategory("MetBrewer") # hide
The colors of Washington State and the Pacific Northwest of the USA. See Jake Lawlor's github repository.
using Luxor, ColorSchemes # hide
ColorSchemeCategory("PNW Pacific North West") # hide
Palettes derived from the films of Wes Anderson. See Karthik's github repository.
using Luxor, ColorSchemes # hide
ColorSchemeCategory("Wes Anderson") # hide
using Luxor, ColorSchemes # hide
ColorSchemeCategory("general") # hide
using Luxor, ColorSchemes # hide
ColorSchemeCategory("nord") # hide
using Luxor, ColorSchemes # hide
ColorSchemeCategory("kindlmann") # hide
using Luxor, ColorSchemes # hide
ColorSchemeCategory("julia") # hide