5

How can I find the HEX representation of Altair default color palette? Every plotting tool has its strengths & weaknesses and I typically end up generating visualizations consist of Seaborn + Altair. I would like to match Altair colors in Seaborn. For Seaborn, you can get the relevant HEX color representation of color_palette as follows and was wondering how can I get similar color information in Altair.

import seaborn as sns
sns.color_palette('Set2').as_hex()
    Out[131]: 
    ['#66c2a5',
     '#fc8d62',
     '#8da0cb',
     '#e78ac3',
     '#a6d854',
     '#ffd92f',
     '#e5c494',
     '#b3b3b3']
jakevdp
  • 77,104
  • 11
  • 125
  • 160
oekici
  • 349
  • 1
  • 5
  • 12

3 Answers3

9

It seems like the default color palette of Altair (from the Vega-Lite renderer) is quite similar to Category 10:

#1f77b4, #ff7f0e, #2ca02c, #d62728, #9467bd,
#8c564b, #e377c2, #7f7f7f, #bcbd22, #17becf

The details of different palettes can be found here: https://d3-wiki.readthedocs.io/zh_CN/master/Ordinal-Scales/

enter image description here

saladi
  • 3,103
  • 6
  • 36
  • 61
oekici
  • 349
  • 1
  • 5
  • 12
4

The color palettes used by Altair are realized in the Vega-Lite renderer, as defined by the vega-scale package.

A human-readable summary is in the Color Schemes section of the Vega documentation. The color schemes are actually defined in schemes.js and palettes.js.

Unfortunately, the color palette details are not available via Altair from the Python package itself.

jakevdp
  • 77,104
  • 11
  • 125
  • 160
2

It looks like my charts in altair are actually using the Tableau 10 color scheme. Hexes are:

#4c78a8
#f58518
#e45756
#72b7b2
#54a24b
#eeca3b
#b279a2
#ff9da6
#9d755d
#bab0ac
ethanabrooks
  • 747
  • 8
  • 19