8000 Make ColormapRegistry callable for backward-compatibility in pyplot. · matplotlib/matplotlib@fe2c958 · GitHub
[go: up one dir, main page]

Skip to content

Commit fe2c958

Browse files
committed
Make ColormapRegistry callable for backward-compatibility in pyplot.
1 parent ac387e2 commit fe2c958

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/matplotlib/cm.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,17 @@ def __str__(self):
140140
return ('ColormapRegistry; available colormaps:\n' +
141141
', '.join(f"'{name}'" for name in self))
142142

143+
def __call__(self):
144+
"""
145+
Return a list of the registered colormap names.
146+
147+
This exists only for backward-compatibilty in `.pyplot` which had a
148+
``plt.colormaps()`` method. The recommended way to get this list is
149+
now ``list(colormaps)``.
150+
"""
151+
return list(self)
152+
153+
143154
def register(self, cmap, *, name=None, force=False):
144155
"""
145156
Register a new colormap.

0 commit comments

Comments
 (0)
0