Skip to content

Instantly share code, notes, and snippets.

@stephtdouglas
Last active January 23, 2023 05:40
Show Gist options
  • Save stephtdouglas/41edd049febfcd3ba8c698efcce612d2 to your computer and use it in GitHub Desktop.
Save stephtdouglas/41edd049febfcd3ba8c698efcce612d2 to your computer and use it in GitHub Desktop.
Color palettes for color blindness from
# http://bconnelly.net/2013/10/creating-colorblind-friendly-figures/
from __future__ import print_function, division
import matplotlib.pyplot as plt
from matplotlib import colors
from cycler import cycler
import numpy as np
palette_names = np.array(["Black", "Orange", "SkyBlue", "#009e73",
"Yellow", "Blue", "#d55e00", "HotPink"])
# This is not actually that different from the GreenOrange Tableau colormap in Palettable
# http://www.somersault1824.com/tips-for-designing-scientific-figures-for-color-blind-readers/
# http://mkweb.bcgsc.ca/biovis2012
from __future__ import print_function, division
import matplotlib.pyplot as plt
from matplotlib import colors
from cycler import cycler
import numpy as np
palette_rgb = np.array([[0,0,0], # 0, black
[0,73,73], # 1, dark teal
[0,146,146], # 2, teal
[255,109,182], # 3, pink
[255,182,119], # 4, light pink
[73,0,146], # 5, purple, except it's plotting as dark green?
[0,109,219], # 6, blue
[182,109,255], # 7, violet
[109,182,255], # 8, light blue
[182,219,255], # 9, even lighter blue
[146,0,0], # 10, red
[146,73,0], # 11, brown
[219,209,0], # 12, orange
[36,255,36], # 13, lime green
[255,255,109]]) # 14, light yellow
cb4 = palette_rgb[np.array([1,3,6,8])]
plt.rc("axes",prop_cycle=(cycler("color",cb4)))
flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
# these don't actually show up like the image?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment