Skip to content

Commit 0a8942d

Browse files
committed
FIX: moved old ScalarMappable methods to a private method
1 parent 8759fe6 commit 0a8942d

File tree

1 file changed

+41
-35
lines changed

1 file changed

+41
-35
lines changed

lib/matplotlib/colorbar.py

+41-35
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,47 @@ def tick_values(self, vmin, vmax):
304304
return ticks
305305

306306

307-
class ColorbarBase(object):
307+
class _ColorbarMappableDummy(object):
308+
"""
309+
Private class to hold deprecated ColorbarBase methods that used to be
310+
inhereted from ScalarMappable.
311+
"""
312+
@cbook.deprecated("3.1", alternative="mappable.set_norm")
313+
def set_norm(self, norm):
314+
"""
315+
`.colorbar.Colorbar.set_norm` does nothing; set the norm on
316+
the mappable associated with this colorbar.
317+
"""
318+
pass
319+
320+
@cbook.deprecated("3.1", alternative="ScalarMappable.set_cmap")
321+
def set_cmap(self, cmap):
322+
"""
323+
`.colorbar.Colorbar.set_cmap` does nothing; set the norm on
324+
the mappable associated with this colorbar.
325+
"""
326+
pass
327+
328+
@cbook.deprecated("3.1", alternative="ScalarMappable.set_clim")
329+
def set_clim(self, cmap):
330+
"""
331+
`.colorbar.Colorbar.set_clim` does nothing; set the limits on
332+
the mappable associated with this colorbar.
333+
"""
334+
pass
335+
336+
@cbook.deprecated("3.1", alternative="ScalarMappable.get_cmap")
337+
def get_cmap(self):
338+
'return the colormap'
339+
return self.cmap
340+
341+
@cbook.deprecated("3.1", alternative="ScalarMappable.get_clim")
342+
def get_clim(self):
343+
'return the min, max of the color limits for image scaling'
344+
return self.norm.vmin, self.norm.vmax
345+
346+
347+
class ColorbarBase(_ColorbarMappableDummy):
308348
'''
309349
Draw a colorbar in an existing axes.
310350
@@ -445,40 +485,6 @@ def draw_all(self):
445485
if self.filled:
446486
self._add_solids(X, Y, C)
447487

448-
@cbook.deprecated("3.1", alternative="mappable.set_norm")
449-
def set_norm(self, norm):
450-
"""
451-
`.colorbar.Colorbar.set_norm` does nothing; set the norm on
452-
the mappable associated with this colorbar.
453-
"""
454-
pass
455-
456-
@cbook.deprecated("3.1", alternative="ScalarMappable.set_cmap")
457-
def set_cmap(self, cmap):
458-
"""
459-
`.colorbar.Colorbar.set_cmap` does nothing; set the norm on
460-
the mappable associated with this colorbar.
461-
"""
462-
pass
463-
464-
@cbook.deprecated("3.1", alternative="ScalarMappable.set_clim")
465-
def set_clim(self, cmap):
466-
"""
467-
`.colorbar.Colorbar.set_clim` does nothing; set the limits on
468-
the mappable associated with this colorbar.
469-
"""
470-
pass
471-
472-
@cbook.deprecated("3.1", alternative="ScalarMappable.get_cmap")
473-
def get_cmap(self):
474-
'return the colormap'
475-
return self.cmap
476-
477-
@cbook.deprecated("3.1", alternative="ScalarMappable.get_clim")
478-
def get_clim(self):
479-
'return the min, max of the color limits for image scaling'
480-
return self.norm.vmin, self.norm.vmax
481-
482488
def config_axis(self):
483489
ax = self.ax
484490

0 commit comments

Comments
 (0)