Skip to content

Commit 0a1b153

Browse files
committed
Add a colorblind friendly heatmap.
1 parent a6a09c1 commit 0a1b153

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/matplotlib/_cm.py

+31
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,36 @@ def gfunc32(x):
18881888
(0.875, 0.50, 0.50),
18891889
(1.000, 1.00, 1.00))}
18901890

1891+
1892+
# A color-blind-friendly heatmap from Wistia:
1893+
# http://wistia.com/blog/heatmaps-for-colorblindness
1894+
#
1895+
# >>> import matplotlib.colors as c
1896+
# >>> colors = np.array([[228,255,122], [254,232,25], [250,190,6],
1897+
# ... [255,159,0], [252,127,0]], dtype=float) / 255
1898+
# ...
1899+
# >>> cm = col.LinearSegmentedColormap.from_list('wistia', colors)
1900+
# >>> _wistia_data = cm._segmentdata
1901+
#
1902+
_wistia_data = {
1903+
'red': [(0.0, 0.89411764705882357, 0.89411764705882357),
1904+
(0.25, 0.99607843137254903, 0.99607843137254903),
1905+
(0.5, 0.98039215686274506, 0.98039215686274506),
1906+
(0.75, 1.0, 1.0),
1907+
(1.0, 0.9882352941176471, 0.9882352941176471)],
1908+
'green': [(0.0, 1.0, 1.0),
1909+
(0.25, 0.90980392156862744, 0.90980392156862744),
1910+
(0.5, 0.74509803921568629, 0.74509803921568629),
1911+
(0.75, 0.62352941176470589, 0.62352941176470589),
1912+
(1.0, 0.49803921568627452, 0.49803921568627452)],
1913+
'blue': [(0.0, 0.47843137254901963, 0.47843137254901963),
1914+
(0.25, 0.098039215686274508, 0.098039215686274508),
1915+
(0.5, 0.023529411764705882, 0.023529411764705882),
1916+
(0.75, 0.0, 0.0),
1917+
(1.0, 0.0, 0.0)]
1918+
}
1919+
1920+
18911921
datad = {
18921922
'afmhot': _afmhot_data,
18931923
'autumn': _autumn_data,
@@ -1963,3 +1993,4 @@ def gfunc32(x):
19631993
datad['gist_stern'] = _gist_stern_data
19641994
datad['gist_yarg'] = _gist_yarg_data
19651995
datad['coolwarm'] = _coolwarm_data
1996+
datad['wistia'] = _wistia_data

0 commit comments

Comments
 (0)