Palettes s2
,
s1
,
s1r
,
economist
, and
mono
contain
colors used for p1
to p15
in official Stata's
schemes files. The palettes
look as follows:
. colorpalette, lcolor(black): s2 / s1 / s1r / economist / mono
Palettes
okabe
,
cblind
,
plottig
,
538
,
mrc
,
tfl
,
burd
, and
lean
provide colors found in various user-contributed scheme files. The palettes
look as follows:
. colorpalette, lcolor(black): okabe / cblind / plottig / 538 / mrc / tfl ///
> / burd / lean
The hue
color generator
has been modeled after function hue_pal()
from R's
scales
package by Hadley Wickham.
Use options n()
(number of colors),
hue()
(range of hues),
chroma()
, and
luminance()
to determine how the colors are generated. Example:
. colorpalette hue, hue(0 -120) chroma(50) luminance(70)
The following example illustrates how the colors change depending on
n()
:
. local palettes . forvalues n = 1/10 { 2. local palettes `palettes' hue, n(`n') name(n=`n') / 3. } . colorpalette, lcolor(black): `palettes'Code
Note that hue
with default
options produces the same colors as HCL intense
.
HCL
provides a
HCL color generator (Hue-Chroma-Luminance; cylindrical representation of CIE L*u*v*). The
implementation is based on R's
colorspace
package. Also
see hclwizard.org.
Three types of color schemes – qualitative, sequential, and diverging – are supported.
See the help file of colorpalette
for details on how the colors are computed. For each type a number of presets are provided. Use options
hue()
,
chroma()
,
luminance()
, and
power()
to modify the presets. Analogous
color generators in the LCh space (cylindrical representation of CIE L*a*b*), and the
CIECAM02-based J'M'h space are available as LCh
and JMh
, respectively.
The HCL
presets look as follows:
. colorpalette, title("Qualitative") lc(black) n(10): ///
> HCL qualitative / HCL intense / HCL dark / HCL light / HCL pastel
Code. local palettes . foreach scheme in blues greens grays oranges purples reds heat heat2 /// > terrain terrain2 viridis plasma redblue { 2. local palettes `palettes' HCL `scheme' / 3. } . colorpalette, title("Sequential") gropts(ysize(5.5) scale(.73)): `palettes'Code
. local palettes . foreach scheme in bluered bluered2 bluered3 greenorange browngreen /// > pinkgreen purplegreen { 2. local palettes `palettes' HCL `scheme' / 3. } . colorpalette, title("Diverging"): `palettes'Code
The HSV
color generator
is similar to the HCL
color generator,
but the colors are generated in the HSV color space (Hue-Saturation-Value).
See the help file of colorpalette
for details. The presets look as follows:
. colorpalette, title("Qualitative") lc(black) n(10): ///
> HSV qualitative / HSV intense / HSV dark / HSV light / ///
> HSV pastel / HSV rainbow
Code. local palettes . foreach scheme in blues greens grays oranges purples reds heat terrain { 2. local palettes `palettes' HSV `scheme' / 3. } . colorpalette, title("Sequential"): `palettes'Code
. local palettes . foreach scheme in bluered bluered2 bluered3 greenorange browngreen /// > pinkgreen purplegreen { 2. local palettes `palettes' HSV `scheme' / 3. } . colorpalette, title("Diverging"): `palettes'Code
A powerful color generator is also provided via the
ipolate()
option. The procedure is to select a start color and an end color, and
perhaps some intermediate colors, and then apply interpolation to generate a
color scale. Several suboptions to select the interpolation space, to set
the positions of the origin colors, or to
affect the shape of the transition between the colors are available; see
the help file of colorpalette
for details. Some examples are as follow:
. colorpalette: #fafa6e #2a4858, ipolate(10) name(Jab) ///
> / #fafa6e #2a4858, ipolate(10, JMh) name(JMh)
Code. colorpalette: #fafa6e #2a4858, ipolate(30, HCL power(1.5)) name(slow) ///
> / #fafa6e #2a4858, ipolate(30, HCL) name(even) ///
> / #fafa6e #2a4858, ipolate(30, HCL power(0.7)) name(fast)
Code. colorpalette: Black Crimson Gold, ipolate(30, pos(0 .3 1)) name(left) ///
> / Black Crimson Gold, ipolate(30) name(middle) ///
> / Black Crimson Gold, ipolate(30, pos(0 .7 1)) name(right)
Code
The d3
collection
provides categorical D3.js
color schemes (see d3-scale):
. colorpalette, lc(black): d3 10 / d3 20 / d3 20b / d3 20c
The colors appear to originate from an earlier versions of
Tableau and are also provided
as tabscheme
:
. colorpalette, lc(black): tab10 / tab20 / tab20b / tab20c
The sb
collection
provides categorical color schemes from seaborn.pydata.org
(same basic colors as tab10
, but in different tones). The palettes come in
a 10-color variant ...
. colorpalette, lc(black): sb deep / sb muted / sb pastel / sb bright ///
> / sb dark / sb colorblind
... and a 6-color variant:
. colorpalette, lc(black): sb deep6 / sb muted6 / sb pastel6 / sb bright6 ///
> / sb dark6 / sb colorblind6
Typing sb
without argument will return sb deep
.
Palette sb deep6
can also be referred to as sb6
.
The pals
collection
provides some categorical color palettes obtained from the
pals package in R:
. colorpalette, lc(black) span: ///
> alphabet / alphabet2 / cols25 / glasbey ///
> / kelly / polychrome / watlington
Code
The tab
collection
provides various color schemes from
Tableau 10:
. colorpalette, title("Qualitative: part 1") lc(black): ///
> tab 10 / tab 20 / tab Color Blind / tab Seattle Grays / tab Traffic ///
> / tab Miller Stone / tab Superfishel Stone / tab Nuriel Stone
Code
Typing tab
without argument will return tab 10
.
. colorpalette, title("Qualitative: part 2") lc(black): ///
> tab Jewel Bright / tab Summer / tab Winter / tab Green-Orange-Teal ///
> / tab Red-Blue-Brown / tab Purple-Pink-Gray / tab Hue Circle
Code. colorpalette, title("Sequential: part 1") span: ///
> tab Blue-Green / tab Blue Light / tab Orange Light / tab Blue / ///
> tab Orange / tab Green / tab Red / tab Purple
Code. colorpalette, title("Sequential: part 2") span: ///
> tab Brown / tab Gray / tab Gray Warm / tab Blue-Teal ///
> / tab Orange-Gold / tab Green-Gold / tab Red-Gold
Code. colorpalette, title("Diverging: part 1"): ///
> tab Orange-Blue / tab Red-Green / tab Green-Blue / tab Red-Blue ///
> / tab Red-Black / tab Gold-Purple / tab Red-Green-Go ///
> / tab Sunset-Sunrise
Code. colorpalette, title("Diverging: part 2"): ///
> tab Orange-Blue-White / tab Red-Green-White / tab Green-Blue-White ///
> / tab Red-Blue-White / tab Red-Black-White / tab Orange-Blue Light ///
> / tab Temperature
Code
The tol
collection
provides various color schemes presented by Paul Tol
at personal.sron.nl/~pault:
. colorpalette, title("Qualitative") lc(black): ///
> tol bright / tol high-contrast / tol vibrant / tol muted ///
> / tol medium-contrast / tol light
Code
Typing tol
without argument will return tol muted
.
. colorpalette, title("Sequential / rainbow / diverging") span: ///
> tol YlOrBr / tol iridescent / tol PuRd / tol PuBr / tol WhRd ///
> / tol WhBr / tol sunset / tol BuRd / tol PRGn
Code
There is also a palette tol rainbow
for which the selection of
colors depends on the size of the palette (1 to 23 colors):
. colorpalette, labels(3 5 10 15 23) title(tol rainbow): ///
> tol rainbow, n(3) / tol rainbow, n(5) / tol rainbow, n(10) ///
> / tol rainbow, n(15) / tol rainbow, n(23)
Code
The ptol
collection
provide some color schemes suggested by
Tol (2012).
The selection of colors depends on the size of the palette:
. colorpalette: ///
> ptol, n(4) / ptol, n(8) / ptol, n(12) ///
> / ptol rainbow, n(4) / ptol rainbow, n(8) / ptol rainbow, n(12) ///
> / ptol diverging, n(3) / ptol diverging, n(7) / ptol diverging, n(11)
Code
The colorbrewer
collection is a set
of color schemes developed by Cynthia Brewer and provided at
colorbrewer2.org. The colors are licensed under Apache
License Version 2.0 (see
copyright note).
The color schemes look as follows:
. colorpalette, title("ColorBrewer qualitative") lcolor(black): ///
> Accent / Dark2 / Paired / Pastel1 / Pastel2 / Set1 / Set2 / Set3
Code. colorpalette, title("ColorBrewer sequential (single hue)"): ///
> Blues / Greens / Greys / Oranges / Purples / Reds
Code. colorpalette, title("ColorBrewer sequential (multi-hue)"): ///
> BuGn / BuPu / GnBu / OrRd / PuBu / PuBuGn / PuRd / RdPu ///
> / YlGn / YlGnBu / YlOrBr / YlOrRd
Code. colorpalette, title("ColorBrewer diverging"): ///
> BrBG / PRGn / PiYG / PuOr / RdBu / RdGy / RdYlBu / RdYlGn / Spectral
CodeFor the sequential and diverging schemes, the colors depend on the size of the palette. For example, here are the 5-color versions of the diverging schemes:
. colorpalette, title("ColorBrewer diverging") n(5): ///
> BrBG / PRGn / PiYG / PuOr / RdBu / RdGy / RdYlBu / RdYlGn / Spectral
Code
The carto
collection provides various color schemes from
Carto.
. colorpalette, title("Qualitative") lc(black) : ///
> carto Antique / carto Bold / carto Pastel / carto Prism ///
> / carto Safe / carto Vivid
Code
Typing carto
without argument will return carto Bold
.
. colorpalette, title("Sequential: part 1"): ///
> carto Burg / carto BurgYl / carto RedOr / carto OrYel / carto Peach ///
> / carto PinkYl / carto Mint / carto BluGrn / carto DarkMint ///
> / carto Emrld / carto ag_GrnYl
Code. colorpalette, title("Sequential: part 2"): ///
> carto BluYl / carto Teal / carto TealGrn / carto Purp ///
> / carto PurpOr / carto Sunset / carto Magenta / carto SunsetDark ///
> / carto ag_Sunset / carto BrwnYl
Code. colorpalette, title("Diverging"): ///
> carto ArmyRose / carto Fall / carto Geyser / carto Temps ///
> / carto TealRose / carto Tropic / carto Earth
Code
The viridis
collection provides perceptually uniform colormaps from
matplotlib
(also see bids.github.io/colormap).
The colormaps are as follows:
. colorpalette, nonumbers: ///
> viridis / plasma / inferno / magma / cividis ///
> / twilight / twilight shifted
twilight
and twilight shifted
are cyclic colormaps.
The seaborn
collection provides perceptually uniform colormaps from
seaborn.pydata.org.
. colorpalette, nonumbers: ///
> rocket / mako / flare / crest / vlag / icefire
The matplotlib
collection
provides several other colormaps
from matplotlib.
. local palettes . foreach scheme in jet autumn spring summer winter bone cool copper /// > coolwarm hot { 2. local palettes `palettes' matplotlib `scheme' / 3. } . colorpalette, nonumbers: `palettes'Code
Typing matplotlib
without argument will return matplotlib jet
.
The CET
collection
provides perceptually uniform colormaps by
Kovesi (2015)
(see colorcet.com/gallery.html).
. colorpalette, title("Linear 1") nonumbers: ///
> CET L01 / CET L02 / CET L03 / CET L04 / CET L05 / CET L06 / CET L07 ///
> / CET L08 / CET L09 / CET L10 / CET L11 / CET L12 / CET L13 / CET L14
Code. colorpalette, title("Linear 2 / rainbow / isoluminant") nonumbers: ///
> CET L15 / CET L16 / CET L17 / CET L18 / CET L19 / CET L20 / CET R1 ///
> / CET R2 / CET R3 / CET R4 / CET I1 / CET I2 / CET I3
Code
Typing CET
without argument will return CET L20
.
. colorpalette, title("Diverging") nonumbers: ///
> CET D01 / CET D01A / CET D02 / CET D03 / CET D04 / CET D06 ///
> / CET D07 / CET D08 / CET D09 / CET D10 / CET D11 / CET D12 / CET D13
Code. colorpalette, title("Circular / colorblind-friendly") nonumbers: ///
> CET C1 / CET C2 / CET C3 / CET C4 / CET C5 / CET C6 / CET C7 ///
> / CET CBD1 / CET CBL1 / CET CBL2 / CET CBC1 / CET CBC2
Code
The scico
collection
provides perceptually uniform colorblind-friendly colormaps by
Crameri (2018)
(see www.fabiocrameri.ch/colourmaps).
. colorpalette, title("Sequential") nonumbers: ///
> scico batlow / scico batlowW / scico batlowK / scico devon ///
> / scico lajolla / scico bamako / scico davos / scico bilbao ///
> / scico nuuk / scico oslo / scico grayC / scico hawaii ///
> / scico lapaz / scico tokyo / scico buda / scico acton ///
> / scico turku / scico imola
Code
Typing scico
without argument will return scico batlow
.
. colorpalette, title("Diverging / cyclic") nonumbers: ///
> scico broc / scico cork / scico vik / scico lisbon / scico tofino ///
> / scico berlin / scico roma / scico bam / scico vanimo ///
> / scico romaO / scico bamO / scico brocO / scico corkO / scico vikO
Code
The lin
collection provides semantic colors
suggested by
Lin et al. (2013):
. local Turkers carcolor food features activities . local Expert fruits vegetables drinks brands . foreach g in Turkers Expert { 2. foreach p in ``g'' { 3. colorpalette lin `p', nograph 4. local clab 5. forv i = 1/`r(n)' { 6. local lbl `"`r(p`i'name)'"' 7. if strlen(`"`lbl'"')>11 { 8. mata: st_local("lbl", mm_invtokens(mm_pieces(`"`lbl'"', 11), 1)) 9. } 10. else { 11. local lbl `""`lbl'" """' 12. } 13. local clab `clab' `i' `"`lbl'"' 14. } 15. if "`p'"=="vegetables" local tplace ", place(1) span" 16. else local tplace 17. colorpalette, plab(`g' Alg.) lc(black) vertical title(`p'`tplace') /// > gropts(ylab(`clab') graphr(m(l=0)) aspectratio(3, place(3)) /// > name(`p', replace) nodraw): lin `p' / lin `p' algorithm 18. } 19. } . graph combine `Turkers' `Expert', rows(2) graphr(margin(zero)) /// > ysize(5) xsize(6.875)Code
The semantic palettes come in two versions: algorithm selected vs.
Turkers or expert selected. For example, lin food
is the Turkers-selected food colors palette, whereas lin food algorithm
is the algorithm-selected food colors palette.
The spmap
collection provides
some color schemes found in spmap
by
Maurizio Pisati:
. colorpalette, n(16): ///
> spmap blues / spmap greens / spmap greys / spmap reds / ///
> spmap rainbow / spmap heat / spmap terrain / spmap topological
Code
The sfso
collection provides
a number of color schemes used by the
Swiss Federal Statistical Office. The schemes look as follows:
. local palettes . foreach scheme in brown orange red pink purple violet blue ltblue /// > turquoise green olive black parties languages votes { 2. local palettes `palettes' sfso `scheme' / 3. } . colorpalette: `palettes'Code
Schemes brown
to black
are sequential schemes that
are often used by the SFSO in line plots and bar graphs. Here is an example (using
grstyle
to change the look
of the graph and assign the colors):
. grstyle init . grstyle color background white . grstyle linewidth major_grid thin . grstyle set color black*.08: plotregion plotregion_line . grstyle set color gs8: axisline tick major_grid . grstyle set horizontal . grstyle set legend 2, nobox stack klength(10) . grstyle set color sfso orange . sysuse uslifeexp, clear (U.S. life expectancy, 1900-1999) . foreach v in le_wfemale le_wmale le_bfemale le_bmale { 2. label variable `v' `"`=substr("`:var lab `v''",18,.)'"' 3. } . line le_wfemale le_wmale le_bfemale le_bmale year, lw(*2.5 ..) /// > ytitle(Life expectancy)Code
parties
and languages
are semantic schemes for
Swiss parties and for the official languages of Switzerland (plus English). The colors for parties are
as follows:
. colorpalette sfso parties
votes
is used for results from popular votes. The following example
displays the results (percent yes) of the
2012 popular initiative against mass immigration
by canton (using
shape data from the SFSO):
. clear all . set obs 26 Number of observations (_N) was 0, now 26. . gen byte _ID = _n . matrix Yes = /// > (47.3, 51.1, 53.3, 58.2, 63.1, 59.1, 58.8, 59.4, 49.9, 48.5, 54.6, 39.0, 50.6, /// > 58.1, 54.4, 63.5, 55.9, 50.6, 55.2, 57.8, 68.2, 38.9, 48.3, 39.3, 39.1, 44.1)' . svmat Yes . colorpalette sfso votes, select(2/4 7/10) nograph . spmap Yes using cantons, id(_ID) legstyle(2) legend(pos(11)) /// > polygon(data(lakes) fcolor(ltblue*.8) ocolor(ebblue*.7) osize(vthin)) /// > clmethod(custom) clbreaks(35 40 45 50 55 60 65 70) fcolor(`r(p)') /// > osize(vthin ..) ocolor(gs8 ..) graphregion(color(gs14))Code
colorpalette
also features a variety of
palettes containing HTML colors
or colors from W3.CSS. See the
help file for more information. For example, various
W3.CSS Color Themes
are supported:
. local palettes . foreach scheme in amber black blue blue-grey brown cyan dark-grey /// > deep-orange deep-purple green grey indigo khaki light-blue /// > light-green lime orange pink purple red teal yellow { 2. local palettes `palettes' w3 `scheme' / 3. } . colorpalette: `palettes'Code
The wesanderson
collection provides Wes Anderson palettes from
wesandersonpalettes.tumblr.com
(the color codes have been obtained from
github.com/karthik/wesanderson).
. colorpalette, lc(black): ///
> BottleRocket1 / BottleRocket2 / Rushmore1 / Royal1 / Royal2 ///
> / Zissou1 / Darjeeling1 / Darjeeling2 / Chevalier1 / FantasticFox1
Code. colorpalette, lc(black): ///
> Moonrise1 / Moonrise2 / Moonrise3 / Cavalcanti1 / GrandBudapest1 ///
> / GrandBudapest2 / IsleofDogs1 / IsleofDogs2 / FrenchDispatch1
Code
The cblind()
option
can be used to simulate color vision deficiency
(deuteranomaly/deuteranopia, protanomaly/protanopia, and
tritanomaly/tritanopia). Example:
. colorpalette: ///
> Set1, name(original) ///
> / Set1, cblind(.5, deut) name(deuteranomaly) ///
> / Set1, cblind(.5, prot) name(protanomaly) ///
> / Set1, cblind(1, trit) name(tritanopia)
Code
Also see colorcheck
for a convenience command to analyze colors with respect to
color vision deficiency.
The gscale()
option
converts colors to gray. Example:
. colorpalette: ///
> s2, name(original) ///
> / s2, gscale(.5) name(50% gray) ///
> / s2, gscale name(100% gray)
Code