From 0a1b15320a21a169fb2848bbf3321b1e673cc391 Mon Sep 17 00:00:00 2001 From: chebee7i Date: Wed, 5 Mar 2014 17:42:50 -0600 Subject: [PATCH 1/5] Add a colorblind friendly heatmap. --- lib/matplotlib/_cm.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/matplotlib/_cm.py b/lib/matplotlib/_cm.py index 601f25a3f92b..cfa3021b104b 100644 --- a/lib/matplotlib/_cm.py +++ b/lib/matplotlib/_cm.py @@ -1888,6 +1888,36 @@ def gfunc32(x): (0.875, 0.50, 0.50), (1.000, 1.00, 1.00))} + +# A color-blind-friendly heatmap from Wistia: +# http://wistia.com/blog/heatmaps-for-colorblindness +# +# >>> import matplotlib.colors as c +# >>> colors = np.array([[228,255,122], [254,232,25], [250,190,6], +# ... [255,159,0], [252,127,0]], dtype=float) / 255 +# ... +# >>> cm = col.LinearSegmentedColormap.from_list('wistia', colors) +# >>> _wistia_data = cm._segmentdata +# +_wistia_data = { + 'red': [(0.0, 0.89411764705882357, 0.89411764705882357), + (0.25, 0.99607843137254903, 0.99607843137254903), + (0.5, 0.98039215686274506, 0.98039215686274506), + (0.75, 1.0, 1.0), + (1.0, 0.9882352941176471, 0.9882352941176471)], + 'green': [(0.0, 1.0, 1.0), + (0.25, 0.90980392156862744, 0.90980392156862744), + (0.5, 0.74509803921568629, 0.74509803921568629), + (0.75, 0.62352941176470589, 0.62352941176470589), + (1.0, 0.49803921568627452, 0.49803921568627452)], + 'blue': [(0.0, 0.47843137254901963, 0.47843137254901963), + (0.25, 0.098039215686274508, 0.098039215686274508), + (0.5, 0.023529411764705882, 0.023529411764705882), + (0.75, 0.0, 0.0), + (1.0, 0.0, 0.0)] +} + + datad = { 'afmhot': _afmhot_data, 'autumn': _autumn_data, @@ -1963,3 +1993,4 @@ def gfunc32(x): datad['gist_stern'] = _gist_stern_data datad['gist_yarg'] = _gist_yarg_data datad['coolwarm'] = _coolwarm_data +datad['wistia'] = _wistia_data From ab31305aaedaa804350ee546abec0fa50639b7cd Mon Sep 17 00:00:00 2001 From: chebee7i Date: Tue, 29 Apr 2014 13:48:47 -0500 Subject: [PATCH 2/5] Update 'wistia' colormap. --- lib/matplotlib/_cm.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/matplotlib/_cm.py b/lib/matplotlib/_cm.py index cfa3021b104b..da752d536a46 100644 --- a/lib/matplotlib/_cm.py +++ b/lib/matplotlib/_cm.py @@ -7,6 +7,8 @@ from __future__ import (absolute_import, division, print_function, unicode_literals) + +import matplotlib.colors import numpy as np _binary_data = { @@ -1890,31 +1892,31 @@ def gfunc32(x): # A color-blind-friendly heatmap from Wistia: +# https://github.com/wistia/heatmap-palette # http://wistia.com/blog/heatmaps-for-colorblindness # # >>> import matplotlib.colors as c -# >>> colors = np.array([[228,255,122], [254,232,25], [250,190,6], -# ... [255,159,0], [252,127,0]], dtype=float) / 255 -# ... -# >>> cm = col.LinearSegmentedColormap.from_list('wistia', colors) +# >>> 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.89411764705882357, 0.89411764705882357), - (0.25, 0.99607843137254903, 0.99607843137254903), - (0.5, 0.98039215686274506, 0.98039215686274506), + '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.90980392156862744, 0.90980392156862744), - (0.5, 0.74509803921568629, 0.74509803921568629), - (0.75, 0.62352941176470589, 0.62352941176470589), - (1.0, 0.49803921568627452, 0.49803921568627452)], + (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.098039215686274508, 0.098039215686274508), - (0.5, 0.023529411764705882, 0.023529411764705882), + (0.25, 0.10196078431372549, 0.10196078431372549), + (0.5, 0.0, 0.0), (0.75, 0.0, 0.0), - (1.0, 0.0, 0.0)] + (1.0, 0.0, 0.0)], } @@ -1993,4 +1995,4 @@ def gfunc32(x): datad['gist_stern'] = _gist_stern_data datad['gist_yarg'] = _gist_yarg_data datad['coolwarm'] = _coolwarm_data -datad['wistia'] = _wistia_data +datad['Wistia'] = _wistia_data From d18f07d47f83bb3e6b79a3ba8af3c2bb4fdfd8e3 Mon Sep 17 00:00:00 2001 From: chebee7i Date: Fri, 2 May 2014 17:25:19 -0500 Subject: [PATCH 3/5] Comments. Add entry to CHANGELOG and whats_new.rst. --- CHANGELOG | 2 ++ doc/users/whats_new.rst | 11 +++++++++++ lib/matplotlib/_cm.py | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 06b958a03c9c..bbdd78445363 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +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). diff --git a/doc/users/whats_new.rst b/doc/users/whats_new.rst index f2edd13786c8..3b46a2f8376d 100644 --- a/doc/users/whats_new.rst +++ b/doc/users/whats_new.rst @@ -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 ` +for more information. + Documentation changes --------------------- diff --git a/lib/matplotlib/_cm.py b/lib/matplotlib/_cm.py index da752d536a46..e6cf0d4dfda3 100644 --- a/lib/matplotlib/_cm.py +++ b/lib/matplotlib/_cm.py @@ -1891,7 +1891,7 @@ def gfunc32(x): (1.000, 1.00, 1.00))} -# A color-blind-friendly heatmap from Wistia: +# An MIT licensed, colorblind-friendly heatmap from Wistia: # https://github.com/wistia/heatmap-palette # http://wistia.com/blog/heatmaps-for-colorblindness # From 5cae0f9c5eeb3352b72f72e12379528de3a39928 Mon Sep 17 00:00:00 2001 From: chebee7i Date: Fri, 2 May 2014 17:31:43 -0500 Subject: [PATCH 4/5] Removing unnecessary import in _cm.py --- lib/matplotlib/_cm.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/_cm.py b/lib/matplotlib/_cm.py index e6cf0d4dfda3..7624b8a88bab 100644 --- a/lib/matplotlib/_cm.py +++ b/lib/matplotlib/_cm.py @@ -8,7 +8,6 @@ from __future__ import (absolute_import, division, print_function, unicode_literals) -import matplotlib.colors import numpy as np _binary_data = { From 28ef5f573b9af501cde67cd46e43cf58929d120b Mon Sep 17 00:00:00 2001 From: chebee7i Date: Fri, 2 May 2014 18:09:14 -0500 Subject: [PATCH 5/5] Minor cosmetics (tabs, alignment) to CHANGELOG. --- CHANGELOG | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index bbdd78445363..9f1b2c86ca5b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,11 @@ 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. @@ -13,16 +13,12 @@ 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 @@ -34,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 @@ -55,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.