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

Skip to content

Commit b50237d

Browse files
committed
Deprecated the set_colorbar method on a scalar mappable.
1 parent bcf4df6 commit b50237d

5 files changed

Lines changed: 8 additions & 6 deletions

File tree

lib/matplotlib/cm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,14 @@ def __init__(self, norm=None, cmap=None):
193193
self.norm = norm
194194
#: The Colormap instance of this ScalarMappable.
195195
self.cmap = get_cmap(cmap)
196+
#: The last colorbar associated with this ScalarMappable. May be None.
196197
self.colorbar = None
197198
self.update_dict = {'array': False}
198199

200+
@cbook.deprecated('1.3', alternative='the colorbar attribute')
199201
def set_colorbar(self, im, ax):
200-
'set the colorbar image and axes associated with mappable'
201-
self.colorbar = im, ax
202+
"""set the colorbar and axes instances associated with mappable"""
203+
self.colorbar = im
202204

203205
def to_rgba(self, x, alpha=None, bytes=False):
204206
"""

lib/matplotlib/colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,6 @@ def colorbar_factory(cax, mappable, **kwargs):
12691269
cb = Colorbar(cax, mappable, **kwargs)
12701270

12711271
mappable.callbacksSM.connect('changed', cb.on_mappable_changed)
1272-
mappable.set_colorbar(cb, cax)
1272+
mappable.colorbar = cb
12731273

12741274
return cb

lib/mpl_toolkits/axes_grid/colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,6 @@ def on_changed(m):
824824
cb.update_bruteforce(m)
825825

826826
cbid = mappable.callbacksSM.connect('changed', on_changed)
827-
mappable.set_colorbar(cb, cax)
827+
mappable.colorbar = cb
828828
ax.figure.sca(ax)
829829
return cb

lib/mpl_toolkits/axes_grid1/axes_grid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def on_changed(m):
9292
cb.update_bruteforce(m)
9393

9494
self.cbid = mappable.callbacksSM.connect('changed', on_changed)
95-
mappable.set_colorbar(cb, self)
95+
mappable.colorbar = cb
9696

9797
self.locator = cb.cbar_axis.get_major_locator()
9898

lib/mpl_toolkits/axes_grid1/colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,6 @@ def on_changed(m):
825825
cb.update_bruteforce(m)
826826

827827
cbid = mappable.callbacksSM.connect('changed', on_changed)
828-
mappable.set_colorbar(cb, cax)
828+
mappable.colorbar = cb
829829
ax.figure.sca(ax)
830830
return cb

0 commit comments

Comments
 (0)