Skip to content

Commit ab3aa58

Browse files
committed
Merge pull request #2871 from chebee7i/cbsafe_heatmap
Add a colorblind friendly heatmap.
2 parents 6cf6063 + 28ef5f5 commit ab3aa58

File tree

3 files changed

+56
-11
lines changed

3 files changed

+56
-11
lines changed

CHANGELOG

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1+
2014-05-02 Added colorblind-friendly colormap, named 'Wistia'.
2+
13
2014-04-27 Improved input clean up in Axes.{h|v}lines
2-
Coerce input into a 1D ndarrays (after dealing with units).
4+
Coerce input into a 1D ndarrays (after dealing with units).
35

46
2014-04-22 Added an example showing the difference between
5-
interpolation = 'none' and interpolation = 'nearest' in
6-
`imshow()` when saving vector graphics files.
7+
interpolation = 'none' and interpolation = 'nearest' in
8+
`imshow()` when saving vector graphics files.
79

810
2014-04-10 Fixed the triangular marker rendering error. The "Up" triangle was
911
rendered instead of "Right" triangle and vice-versa.
1012

1113
2014-04-08 Fixed a bug in parasite_axes.py by making a list out
1214
of a generator at line 263.
1315

14-
2014-02-25 In backend_qt4agg changed from using update -> repaint under
15-
windows. See comment in source near `self._priv_update` for
16-
longer explaination.
17-
1816
2014-03-27 Added tests for pie ccw parameter. Removed pdf and svg images
1917
from tests for pie linewidth parameter.
2018

2119
2014-03-24 Added bool kwarg (manage_xticks) to boxplot to enable/disable
22-
the managemnet of the xlimits and ticks when making a boxplot.
23-
Default in True which maintains current behavior by default.
20+
the managemnet of the xlimits and ticks when making a boxplot.
21+
Default in True which maintains current behavior by default.
2422

2523
2014-03-22 Added the keyword arguments wedgeprops and textprops to pie.
2624
Users can control the wedge and text properties of the pie
@@ -32,9 +30,13 @@
3230

3331
2014-03-13 Add parameter 'clockwise' to function pie, True by default.
3432

35-
2014-27-02 Implemented separate horizontal/vertical axes padding to the
33+
2014-02-27 Implemented separate horizontal/vertical axes padding to the
3634
ImageGrid in the AxesGrid toolkit
3735

36+
2014-02-25 In backend_qt4agg changed from using update -> repaint under
37+
windows. See comment in source near `self._priv_update` for
38+
longer explaination.
39+
3840
2014-01-02 `triplot` now returns the artist it adds and support of line and
3941
marker kwargs has been improved. GBY
4042

@@ -53,7 +55,7 @@
5355
matplotlib.delaunay module. - IMT
5456

5557
2013-11-05 Add power-law normalization method. This is useful for,
56-
e.g., showing small populations in a "hist2d" histogram.
58+
e.g., showing small populations in a "hist2d" histogram.
5759

5860
2013-10-27 Added get_rlabel_position and set_rlabel_position methods to
5961
PolarAxes to control angular position of radial tick labels.

doc/users/whats_new.rst

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ revision, see the :ref:`github-stats`.
2323
new in matplotlib-1.4
2424
=====================
2525

26+
27+
New colormap
28+
------------
29+
In heatmaps, a green-to-red spectrum is often used to indicate intensity of
30+
activity, but this can be problematic for the red/green colorblind. A new,
31+
colorblind-friendly colormap is now available at :class:`matplotlib.cm.Wistia`.
32+
This colormap maintains the red/green symbolism while achieving deuteranopic
33+
legibility through brightness variations. See
34+
`here <https://github.com/wistia/heatmap-palette>`
35+
for more information.
36+
2637
Documentation changes
2738
---------------------
2839

lib/matplotlib/_cm.py

+32
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from __future__ import (absolute_import, division, print_function,
99
unicode_literals)
10+
1011
import numpy as np
1112

1213
_binary_data = {
@@ -1888,6 +1889,36 @@ def gfunc32(x):
18881889
(0.875, 0.50, 0.50),
18891890
(1.000, 1.00, 1.00))}
18901891

1892+
1893+
# An MIT licensed, colorblind-friendly heatmap from Wistia:
1894+
# https://github.com/wistia/heatmap-palette
1895+
# http://wistia.com/blog/heatmaps-for-colorblindness
1896+
#
1897+
# >>> import matplotlib.colors as c
1898+
# >>> colors = ["#e4ff7a", "#ffe81a", "#ffbd00", "#ffa000", "#fc7f00"]
1899+
# >>> cm = c.LinearSegmentedColormap.from_list('wistia', colors)
1900+
# >>> _wistia_data = cm._segmentdata
1901+
# >>> del _wistia_data['alpha']
1902+
#
1903+
_wistia_data = {
1904+
'red': [(0.0, 0.8941176470588236, 0.8941176470588236),
1905+
(0.25, 1.0, 1.0),
1906+
(0.5, 1.0, 1.0),
1907+
(0.75, 1.0, 1.0),
1908+
(1.0, 0.9882352941176471, 0.9882352941176471)],
1909+
'green': [(0.0, 1.0, 1.0),
1910+
(0.25, 0.9098039215686274, 0.9098039215686274),
1911+
(0.5, 0.7411764705882353, 0.7411764705882353),
1912+
(0.75, 0.6274509803921569, 0.6274509803921569),
1913+
(1.0, 0.4980392156862745, 0.4980392156862745)],
1914+
'blue': [(0.0, 0.47843137254901963, 0.47843137254901963),
1915+
(0.25, 0.10196078431372549, 0.10196078431372549),
1916+
(0.5, 0.0, 0.0),
1917+
(0.75, 0.0, 0.0),
1918+
(1.0, 0.0, 0.0)],
1919+
}
1920+
1921+
18911922
datad = {
18921923
'afmhot': _afmhot_data,
18931924
'autumn': _autumn_data,
@@ -1963,3 +1994,4 @@ def gfunc32(x):
19631994
datad['gist_stern'] = _gist_stern_data
19641995
datad['gist_yarg'] = _gist_yarg_data
19651996
datad['coolwarm'] = _coolwarm_data
1997+
datad['Wistia'] = _wistia_data

0 commit comments

Comments
 (0)