@@ -1976,6 +1976,10 @@ class SubFigure(FigureBase):
1976
1976
1977
1977
See :doc:`/gallery/subplots_axes_and_figures/subfigures`
1978
1978
"""
1979
+ callbacks = _api .deprecated (
1980
+ "3.6" ,alternative = ("the 'resize_event' signal in "
1981
+ "Figure.canvas.callbacks" )
1982
+ )(property (lambda self :self ._fig_callbacks ))
1979
1983
1980
1984
def __init__ (self ,parent ,subplotspec ,* ,
1981
1985
facecolor = None ,
@@ -2024,7 +2028,7 @@ def __init__(self, parent, subplotspec, *,
2024
2028
self ._subplotspec = subplotspec
2025
2029
self ._parent = parent
2026
2030
self .figure = parent .figure
2027
- self .callbacks = parent .callbacks
2031
+ self ._fig_callbacks = parent ._fig_callbacks
2028
2032
2029
2033
# subfigures use the parent axstack
2030
2034
self ._axstack = parent ._axstack
@@ -2156,11 +2160,6 @@ class Figure(FigureBase):
2156
2160
"""
2157
2161
The top level container for all the plot elements.
2158
2162
2159
- The Figure instance supports callbacks through a *callbacks* attribute
2160
- which is a `.CallbackRegistry` instance. The events you can connect to
2161
- are 'dpi_changed', and the callback will be called with ``func(fig)`` where
2162
- fig is the `Figure` instance.
2163
-
2164
2163
Attributes
2165
2164
----------
2166
2165
patch
@@ -2171,6 +2170,12 @@ class Figure(FigureBase):
2171
2170
depending on the renderer option_image_nocomposite function. If
2172
2171
*suppressComposite* is a boolean, this will override the renderer.
2173
2172
"""
2173
+ # Remove the self._fig_callbacks properties on figure and subfigure
2174
+ # after the deprecation expires.
2175
+ callbacks = _api .deprecated (
2176
+ "3.6" ,alternative = ("the 'resize_event' signal in "
2177
+ "Figure.canvas.callbacks" )
2178
+ )(property (lambda self :self ._fig_callbacks ))
2174
2179
2175
2180
def __str__ (self ):
2176
2181
return "Figure(%gx%g)" % tuple (self .bbox .size )
@@ -2303,7 +2308,7 @@ def __init__(self,
2303
2308
# everything is None, so use default:
2304
2309
self .set_layout_engine (layout = layout )
2305
2310
2306
- self .callbacks = cbook .CallbackRegistry (signals = ["dpi_changed" ])
2311
+ self ._fig_callbacks = cbook .CallbackRegistry (signals = ["dpi_changed" ])
2307
2312
# Callbacks traditionally associated with the canvas (and exposed with
2308
2313
# a proxy property), but that actually need to be on the figure for
2309
2314
# pickling.
@@ -2502,7 +2507,7 @@ def _set_dpi(self, dpi, forward=True):
2502
2507
self .dpi_scale_trans .clear ().scale (dpi )
2503
2508
w ,h = self .get_size_inches ()
2504
2509
self .set_size_inches (w ,h ,forward = forward )
2505
- self .callbacks .process ('dpi_changed' ,self )
2510
+ self ._fig_callbacks .process ('dpi_changed' ,self )
2506
2511
2507
2512
dpi = property (_get_dpi ,_set_dpi ,doc = "The resolution in dots per inch." )
2508
2513