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

Skip to content

Commit f37729d

Browse files
author
pelson
committed
Full support for string cmaps.
1 parent 70c2cbb commit f37729d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

lib/matplotlib/cm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ def get_cmap(name=None, lut=None):
151151
return cmap_d[name]
152152
elif name in datad:
153153
return _generate_cmap(name, lut)
154-
else:
155-
raise ValueError("Colormap %s is not recognized" % name)
154+
155+
raise ValueError("Colormap %s is not recognized" % name)
156156

157157
class ScalarMappable:
158158
"""

lib/matplotlib/contour.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,6 @@ def __init__(self, ax, *args, **kwargs):
766766
if self.origin is not None: assert(self.origin in
767767
['lower', 'upper', 'image'])
768768
if self.extent is not None: assert(len(self.extent) == 4)
769-
if cmap is not None: assert(isinstance(cmap, colors.Colormap))
770769
if self.colors is not None and cmap is not None:
771770
raise ValueError('Either colors or cmap must be None')
772771
if self.origin == 'image': self.origin = mpl.rcParams['image.origin']

lib/matplotlib/streamplot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
import matplotlib
77
import matplotlib.patches as patches
8-
8+
from matplotlib.cm import get_cmap
99

1010
__all__ = ['streamplot']
1111

@@ -105,7 +105,9 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None,
105105
if norm is None:
106106
norm = matplotlib.colors.normalize(color.min(), color.max())
107107
if cmap is None:
108-
cmap = matplotlib.cm.get_cmap(matplotlib.rcParams['image.cmap'])
108+
cmap = get_cmap(matplotlib.rcParams['image.cmap'])
109+
else:
110+
cmap = get_cmap(cmap)
109111

110112
streamlines = []
111113
for t in trajectories:

0 commit comments

Comments
 (0)