diff --git a/doc/api/next_api_changes/deprecations/20799-GL.rst b/doc/api/next_api_changes/deprecations/20799-GL.rst new file mode 100644 index 000000000000..5c713cfa2ed3 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/20799-GL.rst @@ -0,0 +1,3 @@ +``ScalarMappable.callbacksSM`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +is deprecated. Use ``ScalarMappable.callbacks`` instead. diff --git a/doc/api/next_api_changes/removals/19552-GL.rst b/doc/api/next_api_changes/removals/19552-GL.rst index 8606c64ebbf0..be0bebd3d89e 100644 --- a/doc/api/next_api_changes/removals/19552-GL.rst +++ b/doc/api/next_api_changes/removals/19552-GL.rst @@ -2,4 +2,4 @@ ScalarMappable update checkers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``ScalarMappable.update_dict``, ``ScalarMappable.add_checker()``, and ``ScalarMappable.check_update()`` have been removed. A callback can -be registered in ``ScalarMappable.callbacksSM`` to be notified of updates. \ No newline at end of file +be registered in ``ScalarMappable.callbacks`` to be notified of updates. \ No newline at end of file diff --git a/examples/images_contours_and_fields/multi_image.py b/examples/images_contours_and_fields/multi_image.py index 82b1a072a1b6..e517e3f326ca 100644 --- a/examples/images_contours_and_fields/multi_image.py +++ b/examples/images_contours_and_fields/multi_image.py @@ -47,7 +47,7 @@ def update(changed_image): for im in images: - im.callbacksSM.connect('changed', update) + im.callbacks.connect('changed', update) plt.show() diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 8f1417d5551c..ec7f3f75feb0 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4923,7 +4923,7 @@ def on_changed(collection): vbar.set_cmap(collection.get_cmap()) vbar.set_clim(collection.get_clim()) - collection.callbacksSM.connect('changed', on_changed) + collection.callbacks.connect('changed', on_changed) return collection diff --git a/lib/matplotlib/cm.py b/lib/matplotlib/cm.py index 6d05be943b33..aefdf40698a4 100644 --- a/lib/matplotlib/cm.py +++ b/lib/matplotlib/cm.py @@ -263,7 +263,10 @@ def __init__(self, norm=None, cmap=None): self.set_cmap(cmap) # The Colormap instance of this ScalarMappable. #: The last colorbar associated with this ScalarMappable. May be None. self.colorbar = None - self.callbacksSM = cbook.CallbackRegistry() + self.callbacks = cbook.CallbackRegistry() + + callbacksSM = _api.deprecated("3.5", alternative="callbacks")( + property(lambda self: self.callbacks)) def _scale_norm(self, norm, vmin, vmax): """ @@ -495,5 +498,5 @@ def changed(self): Call this whenever the mappable is changed to notify all the callbackSM listeners to the 'changed' signal. """ - self.callbacksSM.process('changed', self) + self.callbacks.process('changed', self) self.stale = True diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index 0b8953d5241f..69133b4dd7cb 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -404,7 +404,7 @@ def __init__(self, ax, mappable=None, *, cmap=None, alpha = mappable.get_alpha() mappable.colorbar = self - mappable.colorbar_cid = mappable.callbacksSM.connect( + mappable.colorbar_cid = mappable.callbacks.connect( 'changed', self.update_normal) _api.check_in_list( @@ -981,7 +981,7 @@ def remove(self): """ self.ax.remove() - self.mappable.callbacksSM.disconnect(self.mappable.colorbar_cid) + self.mappable.callbacks.disconnect(self.mappable.colorbar_cid) self.mappable.colorbar = None self.mappable.colorbar_cid = None
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: