Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80fa23e

Browse files
committed
DOC: Update docs about qualitative colormaps
They are now ListedColormap; remove note about them being possibly removed. Add notes to What's New and API Changes. Also added reminder to update the colormap documentation if you add a new colormap or change an existing one
1 parent df3b769 commit 80fa23e

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Qualitative colormaps
2+
---------------------
3+
4+
Colorbrewer's qualitative/discrete colormaps ("Accent", "Dark2", "Paired",
5+
"Pastel1", "Pastel2", "Set1", "Set2", "Set3") are now implemented as
6+
``ListedColormap`` instead of ``LinearSegmentedColormap``.
7+
8+
To use these for images where categories are specified as integers, for
9+
instance, use::
10+
11+
plt.imshow(x, cmap='Dark2', norm=colors.NoNorm())
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Qualitative colormaps
2+
---------------------
3+
4+
ColorBrewer's "qualitative" colormaps ("Accent", "Dark2", "Paired",
5+
"Pastel1", "Pastel2", "Set1", "Set2", "Set3") were intended for discrete
6+
categorical data, with no implication of value, and therefore have been
7+
converted to ``ListedColormap`` instead of ``LinearSegmentedColormap``, so
8+
the colors will no longer be interpolated and they can be used for
9+
choropleths, labeled image features, etc.

lib/matplotlib/_cm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
Nothing here but dictionaries for generating LinearSegmentedColormaps,
33
and a dictionary of these dictionaries.
44
5-
Documentation for each is in pyplot.colormaps()
5+
Documentation for each is in pyplot.colormaps(). Please update this
6+
with the purpose and type of your colormap if you add data for one here.
67
"""
78

89
from __future__ import (absolute_import, division, print_function,

lib/matplotlib/pyplot.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,11 +2060,9 @@ def colormaps():
20602060
20612061
ColorBrewer Qualitative:
20622062
2063-
(For plotting nominal data, :class:`ListedColormap` should be used,
2063+
(For plotting nominal data, :class:`ListedColormap` is used,
20642064
not :class:`LinearSegmentedColormap`. Different sets of colors are
2065-
recommended for different numbers of categories. These continuous
2066-
versions of the qualitative schemes may be removed or converted in the
2067-
future.)
2065+
recommended for different numbers of categories.)
20682066
20692067
* Accent
20702068
* Dark2

0 commit comments

Comments
 (0)