Skip to content

Add a colorblind friendly heatmap. #2871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
2014-05-02 Added colorblind-friendly colormap, named 'Wistia'.

2014-04-27 Improved input clean up in Axes.{h|v}lines
Coerce input into a 1D ndarrays (after dealing with units).
Coerce input into a 1D ndarrays (after dealing with units).

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

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

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

2014-02-25 In backend_qt4agg changed from using update -> repaint under
windows. See comment in source near `self._priv_update` for
longer explaination.

2014-03-27 Added tests for pie ccw parameter. Removed pdf and svg images
from tests for pie linewidth parameter.

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

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

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

2014-27-02 Implemented separate horizontal/vertical axes padding to the
2014-02-27 Implemented separate horizontal/vertical axes padding to the
ImageGrid in the AxesGrid toolkit

2014-02-25 In backend_qt4agg changed from using update -> repaint under
windows. See comment in source near `self._priv_update` for
longer explaination.

2014-01-02 `triplot` now returns the artist it adds and support of line and
marker kwargs has been improved. GBY

Expand All @@ -53,7 +55,7 @@
matplotlib.delaunay module. - IMT

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

2013-10-27 Added get_rlabel_position and set_rlabel_position methods to
PolarAxes to control angular position of radial tick labels.
Expand Down
11 changes: 11 additions & 0 deletions doc/users/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ revision, see the :ref:`github-stats`.
new in matplotlib-1.4
=====================


New colormap
------------
In heatmaps, a green-to-red spectrum is often used to indicate intensity of
activity, but this can be problematic for the red/green colorblind. A new,
colorblind-friendly colormap is now available at :class:`matplotlib.cm.Wistia`.
This colormap maintains the red/green symbolism while achieving deuteranopic
legibility through brightness variations. See
`here <https://github.com/wistia/heatmap-palette>`
for more information.

Documentation changes
---------------------

Expand Down
32 changes: 32 additions & 0 deletions lib/matplotlib/_cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from __future__ import (absolute_import, division, print_function,
unicode_literals)

import numpy as np

_binary_data = {
Expand Down Expand Up @@ -1888,6 +1889,36 @@ def gfunc32(x):
(0.875, 0.50, 0.50),
(1.000, 1.00, 1.00))}


# An MIT licensed, colorblind-friendly heatmap from Wistia:
# https://github.com/wistia/heatmap-palette
# http://wistia.com/blog/heatmaps-for-colorblindness
#
# >>> import matplotlib.colors as c
# >>> colors = ["#e4ff7a", "#ffe81a", "#ffbd00", "#ffa000", "#fc7f00"]
# >>> cm = c.LinearSegmentedColormap.from_list('wistia', colors)
# >>> _wistia_data = cm._segmentdata
# >>> del _wistia_data['alpha']
#
_wistia_data = {
'red': [(0.0, 0.8941176470588236, 0.8941176470588236),
(0.25, 1.0, 1.0),
(0.5, 1.0, 1.0),
(0.75, 1.0, 1.0),
(1.0, 0.9882352941176471, 0.9882352941176471)],
'green': [(0.0, 1.0, 1.0),
(0.25, 0.9098039215686274, 0.9098039215686274),
(0.5, 0.7411764705882353, 0.7411764705882353),
(0.75, 0.6274509803921569, 0.6274509803921569),
(1.0, 0.4980392156862745, 0.4980392156862745)],
'blue': [(0.0, 0.47843137254901963, 0.47843137254901963),
(0.25, 0.10196078431372549, 0.10196078431372549),
(0.5, 0.0, 0.0),
(0.75, 0.0, 0.0),
(1.0, 0.0, 0.0)],
}


datad = {
'afmhot': _afmhot_data,
'autumn': _autumn_data,
Expand Down Expand Up @@ -1963,3 +1994,4 @@ def gfunc32(x):
datad['gist_stern'] = _gist_stern_data
datad['gist_yarg'] = _gist_yarg_data
datad['coolwarm'] = _coolwarm_data
datad['Wistia'] = _wistia_data