Skip to content

Instantly share code, notes, and snippets.

@KalebNyquist
Created June 19, 2022 05:20
Show Gist options
  • Save KalebNyquist/965e2c2b5512026817ed9aec69bbe278 to your computer and use it in GitHub Desktop.
Save KalebNyquist/965e2c2b5512026817ed9aec69bbe278 to your computer and use it in GitHub Desktop.
Favorite Palettes
# Some of my favorite color palettes, including the original sources and the code I used to customize them to my liking
# Used as reference: http://tsitsul.in/img/colors/all_palettes/tableau.20.colorblind.png | http://tsitsul.in/blog/coloropt/
xgfs_normal11 = [(235, 172, 35), (184, 0, 88), (0, 140, 249), (0, 110, 0), (0, 187, 173), (209, 99, 230), (178, 69, 2), (255, 146, 135), (89, 84, 214), (0, 198, 248), (135, 133, 0), (0, 167, 108)]
xgfs_greys = [(88, 88, 88), (238, 238, 238)]
tableau_18 = [[ 31, 119, 180], [174, 199, 232], [255, 127, 14], [255, 187, 120], [ 44, 160, 44], [152, 223, 138], [214, 39, 40], [255, 152, 150], [148, 103, 189], [197, 176, 213], [140, 86, 75], [196, 156, 148], [227, 119, 194], [247, 182, 210], [188, 189, 34], [219, 219, 141], [ 23, 190, 207], [158, 218, 229]]
tableau_grey = [[127, 127, 127], [199, 199, 199]]
# Convert to Hex
from matplotlib import colors
palette = [colors.to_hex([x/255 for x in y]) for y in tableau_18]
# Remix tableau so that similar colors are not adjacent
odds = [x for i, x in enumerate(palette) if i % 2 == 0]
evens = [x for i, x in enumerate(palette) if i % 2 == 1]
palette = odds[0:5] + odds[5:] + evens[0:5] + evens[5:]
greys = [colors.to_hex([x/255 for x in y]) for y in tableau_grey]
# palette = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#bcbd22', '#17becf', '#aec7e8', '#ffbb78', '#98df8a', '#ff9896', '#c5b0d5', '#c49c94', '#f7b6d2', '#dbdb8d', '#9edae5']
# greys = ['#7f7f7f', '#c7c7c7']
# XGFS
palette = [colors.to_hex([x/255 for x in y]) for y in xgfs_normal11]
greys = [colors.to_hex([x/255 for x in y]) for y in xgfs_grey]
# palette = ['#ebac23', '#b80058', '#008cf9', '#006e00', '#00bbad', '#d163e6', '#b24502', '#ff9287', '#5954d6', '#00c6f8', '#878500', '#00a76c']
# greys = ['#585858', '#eeeeee']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment