Stata palettes

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
colors/stata.svg
[top]

Other palettes

Palettes 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): cblind / plottig / 538 / mrc / tfl / burd / lean
colors/other.svg
[top]

Color generators

Evenly spaced HCL hues

The hue palette 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)
colors/hue0.svg

The following example illustrates how the colors change depending on n():

. local palettes

. local plab

. forvalues n = 1/10 {
  2.     local palettes `palettes' hue, n(`n') /
  3.     local plab `plab' n(`n')
  4. }

. colorpalette, lcolor(black) plabels(`plab'): `palettes'
Code
colors/hue.svg

Note that hue with default options produces the same colors as hcl, intense.

[top]

HCL color generator

The hcl palette is a HCL color generator (Hue-Chroma-Luminance). 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.

The presets look as follows:

. colorpalette, title("HCL qualitative") lc(black) n(10) ///
>     plabels(qualitative intense dark light pastel): ///
>     hcl, qualitative / hcl, intense / hcl, dark / hcl, light / hcl, pastel
Code
colors/hcl.svg
. local schemes blues greens grays oranges purples reds heat heat2 ///
>     terrain terrain2 viridis plasma redblue

. local palettes

. foreach scheme of local schemes {
  2.     local palettes `palettes' hcl, `scheme' /
  3. }

. colorpalette, title("HCL sequential") plabels(`schemes') ///
>     gropts(ysize(5.5) scale(.73)): `palettes'
Code
colors/hclseq.svg
. local schemes bluered bluered2 bluered3 greenorange browngreen pinkgreen purplegreen

. local palettes

. foreach scheme of local schemes {
  2.     local palettes `palettes' hcl, `scheme' /
  3. }

. colorpalette, title("HCL diverging") plabels(`schemes'): `palettes'
Code
colors/hcldiv.svg
[top]

HSV color generator

The hsv palette is similar to the hcl palette, 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("HSV qualitative") lc(black) n(10) ///
>     plabels(qualitative intense dark light pastel): ///
>     hsv, qualitative / hsv, intense / hsv, dark / hsv, light / ///
>     hsv, pastel / hsv, rainbow
Code
colors/hsv.svg
. local schemes blues greens grays oranges purples reds heat terrain

. local palettes

. foreach scheme of local schemes {
  2.     local palettes `palettes' hsv, `scheme' /
  3. }

. colorpalette, title("HSV sequential") plabels(`schemes'): `palettes'
Code
colors/hsvseq.svg
. local schemes bluered bluered2 bluered3 greenorange browngreen pinkgreen purplegreen

. local palettes

. foreach scheme of local schemes {
  2.     local palettes `palettes' hsv, `scheme' /
  3. }

. colorpalette, title("HSV diverging") plabels(`schemes'): `palettes'
Code
colors/hsvdiv.svg
[top]

Collections

ColorBrewer

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
colors/qualitative.svg
. colorpalette, title("ColorBrewer sequential (single hue)"): ///
>     Blues / Greens / Greys / Oranges / Purples / Reds
colors/seq1.svg
. colorpalette, title("ColorBrewer sequential (multi-hue)"): ///
>     BuGn / BuPu / GnBu / OrRd / PuBu / PuBuGn / PuRd / RdPu ///
>     / YlGn / YlGnBu / YlOrBr / YlOrRd
colors/seq2.svg
. colorpalette, title("ColorBrewer diverging"): ///
>     BrBG / PRGn / PiYG / PuOr / RdBu / RdGy / RdYlBu / RdYlGn / Spectral
colors/diverging.svg

For 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
colors/diverging5.svg
[top]

Palettes by Tol (2012)

The ptol palette 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, diverging n(3) / ptol, diverging n(7) / ptol, diverging n(11) ///
>     / ptol, rainbow n(4)   / ptol, rainbow n(8)   / ptol, rainbow n(12)
colors/paultol.svg
[top]

D3 category scales

The d3 palette provides some categorical D3.js color schemes (see d3-scale):

. colorpalette: d3, 10 / d3, 20 / d3, 20b / d3, 20c
colors/d3.svg
[top]

Semantic colors

The lin palette 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'info)'"'
  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
colors/semantic.svg

The semantic palettes come in two versions: algorithm selected vs. Turkers or expert selected. Specify option algorithm to request the algorithm selected colors.

[top]

Colors from spmap

The spmap palette 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
colors/spmap.svg

Schemes blues2 to rainbow provide between 2 and 99 colors, schemes heat, terrain, and topological provide between 2 and 16 colors.

[top]

Swiss Federal Statistical Office

The sfso palette provides a number of color schemes used by the Swiss Federal Statistical Office. The schemes look as follows:

. local schemes brown orange red pink purple violet blue ltblue turquoise ///
>     green olive black parties languages votes

. local palettes

. foreach scheme of local schemes {
  2.     local palettes `palettes' sfso, `scheme' /
  3. }

. colorpalette, plabels(`schemes'): `palettes'
Code
colors/SFSO.svg

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
colors/SFSOorange.svg

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
colors/SFSOparties.svg

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 nograph select(2/4 7/10)

. 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
colors/SFSOvotes.svg