Epidemiology & Technology

Stata Graph Colors

Install the packages contributed by Ben Jann: here and here in the Stata Journal.

ssc install grstyle, replace
ssc install palettes, replace
ssc install colrspace, replace
adoupdate grstyle palettes colrspace


net install grstyle, replace from(https://raw.githubusercontent.com/benjann/grstyle/master/)
net install palettes, replace from(https://raw.githubusercontent.com/benjann/palettes/master/)
net install colrspace, replace from(https://raw.githubusercontent.com/benjann/colrspace/master/)Code language: Stata (stata)

Initialize and set the preferred graph schemes. Here I am setting plain background with dotted grid and legend without any box at 2 o-clock inside graph region. Detailed help for grstyle is there.

grstyle init
grstyle set plain, grid dotted
grstyle set legend 2, nobox  insideCode language: Stata (stata)

Assigning Colors

Examples

View all colorpalettes here. Various schemes are available: Many of these schemes have variants within them. Some Color blindness friendly palettes include:

  • cblind
  • tab Color Blind
  • sb colorblind6
  • sb colorblind
  • CET C1 / CET C2 / CET C3 / CET C4 / CET C5 / CET C6 / CET C7 / / CET CBD1 / CET CBL1 / CET CBL2 / CET CBC1 / CET CBC2
  • 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
Qualitative Palettes: link
  • s1
  • s2
  • s2r
  • economist
  • mono
  • okabe
  • cblind
  • plottig
  • 538
  • mrc
  • tfl
  • burd
  • lean
Collections with multiple schemes/palettes
  • D3 JS: d3 10 / d3 20 / d3 20b / d3 20c
  • tab: from Tableau:
    • tab 10 / tab 20 / tab Color Blind / tab Seattle Grays / tab Traffic / tab Miller Stone / tab Superfishel Stone / tab Nuriel Stone
    • tab Jewel Bright / tab Summer / tab Winter / tab Green-Orange-Teal / tab Red-Blue-Brown / tab Purple-Pink-Gray / tab Hue Circle
    • tab Blue-Green / tab Blue Light / tab Orange Light / tab Blue / tab Orange / tab Green / tab Red / tab Purple
    • tab Brown / tab Gray / tab Gray Warm / tab Blue-Teal / tab Orange-Gold / tab Green-Gold / tab Red-Gold
    • 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
    • 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
  • sb : sb deep / sb muted / sb pastel / sb bright / sb dark / sb colorblind / sb deep6 / sb muted6 / sb pastel6 / sb bright6 / sb dark6 / sb colorblind6
  • pals: alphabet / alphabet2 / cols25 / glasbey / kelly / polychrome / watlington
  • tol:
    • tol bright / tol high-contrast / tol vibrant / tol muted / tol medium-contrast / tol light
    • tol YlOrBr / tol iridescent / tol PuRd / tol PuBr / tol WhRd / tol WhBr / tol sunset / tol BuRd / tol PRGn
    • tol rainbow, n(3) / tol rainbow, n(5) / tol rainbow, n(10) / tol rainbow, n(15) / tol rainbow, n(23)
  • ptol: 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)
  • carto
    • carto Antique / carto Bold / carto Pastel / carto Prism / carto Safe / carto Vivid
    • carto Burg / carto BurgYl / carto RedOr / carto OrYel / carto Peach / carto PinkYl / carto Mint / carto BluGrn / carto DarkMint / carto Emrld / carto ag_GrnYl
    • carto BluYl / carto Teal / carto TealGrn / carto Purp / carto PurpOr / carto Sunset / carto Magenta / carto SunsetDark / carto ag_Sunset / carto BrwnYl
    • carto ArmyRose / carto Fall / carto Geyser / carto Temps / carto TealRose / carto Tropic / carto Earth
  • ColorBrewer
    • Accent / Dark2 / Paired / Pastel1 / Pastel2 / Set1 / Set2 / Set3
    • Blues / Greens / Greys / Oranges / Purples / Reds
    • BuGn / BuPu / GnBu / OrRd / PuBu / PuBuGn / PuRd / RdPu / YlGn / YlGnBu / YlOrBr / YlOrRd
    • BrBG / PRGn / PiYG / PuOr / RdBu / RdGy / RdYlBu / RdYlGn / Spectral
    • BrBG / PRGn / PiYG / PuOr / RdBu / RdGy / RdYlBu / RdYlGn / Spectral
  • lin
    • lin carcolor / lin food / lin features / lin activities / lin fruits / lin vegetables / lin drinks / lin brands
    • lin carcolor algorithm / lin food algorithm / lin features algorithm / lin activities algorithm / lin fruits algorithm / lin vegetables algorithm / lin drinks algorithm / lin brands algorithm
  • maplotlib:
    • viridis / plasma / inferno / magma / cividis / twilight / twilight shifted
    • matplotlib jet / matplotlib autumn / matplotlib spring / matplotlib summer / matplotlib winter / matplotlib bone / matplotlib cool / matplotlib copper / matplotlib coolwarm / matplotlib hot /
  • seaborn: rocket / mako / flare / crest / vlag / icefire
  • CET:
    • 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
    • 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
    • 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
    • CET C1 / CET C2 / CET C3 / CET C4 / CET C5 / CET C6 / CET C7 / CET CBD1 / CET CBL1 / CET CBL2 / CET CBC1 / CET CBC2
  • HTML collection
  • W3 collection
  • Scientific
    • 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
    • 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
  • Wes Anderson
    • BottleRocket1 / BottleRocket2 / Rushmore1 / Royal1 / Royal2 / Zissou1 / Darjeeling1 / Darjeeling2 / Chevalier1 / FantasticFox1
    • Moonrise1 / Moonrise2 / Moonrise3 / Cavalcanti1 / GrandBudapest1 / GrandBudapest2 / IsleofDogs1 / IsleofDogs2 / FrenchDispatch1
Color generators
  • HCL: colorpalette, title(“Qualitative”) lc(black) n(10): HCL qualitative / HCL intense / HCL dark / HCL light / HCL pastel
  • HSV: colorpalette, title(“Qualitative”) lc(black) n(10): HSV qualitative / HSV intense / HSV dark / HSV light / HSV pastel / HSV rainbow

Usage of palettes and collections

grstyle set color economist
grstyle set color tfl
grstyle set color lean
grstyle set color okabe
grstyle set color tab Color BlindCode language: JavaScript (javascript)
grstyle set color ptol rainbow, n(8) reverse
grstyle set color hue, n(4)
qrstyle set color Greens, n(8)
grstyle set color hue, n(4)
grstyle set color #286090 #449d44 #31b0d5 #ec971f #c9302c
grstyle set color Accent
Code language: JavaScript (javascript)

Related Posts