Skip to content

Commit

Permalink
Merge pull request matplotlib#19858 from anntzer/unitsfinalize
Browse files Browse the repository at this point in the history
Move Line2D units handling to Axes & deprecate "units finalize" signal.
  • Loading branch information
timhoffm authored Apr 7, 2021
2 parents 17a7bb1 + aa4b36c commit 7d87722
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations/19858-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"units finalize" signal
~~~~~~~~~~~~~~~~~~~~~~~
This signal (previously emitted by Axis instances) is deprecated. Connect to
"units" instead.
4 changes: 3 additions & 1 deletion lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def __init__(self, fig, rect,
for name, axis in self._get_axis_map().items():
axis.callbacks._pickled_cids.add(
axis.callbacks.connect(
'units finalize', self._unit_change_handler(name)))
'units', self._unit_change_handler(name)))

rcParams = mpl.rcParams
self.tick_params(
Expand Down Expand Up @@ -2402,6 +2402,8 @@ def _unit_change_handler(self, axis_name, event=None):
return functools.partial(
self._unit_change_handler, axis_name, event=object())
_api.check_in_list(self._get_axis_map(), axis_name=axis_name)
for line in self.lines:
line.recache_always()
self.relim()
self._request_autoscale_view(scalex=(axis_name == "x"),
scaley=(axis_name == "y"))
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def __setstate__(self, state):
@_api.rename_parameter("3.4", "s", "signal")
def connect(self, signal, func):
"""Register *func* to be called when signal *signal* is generated."""
if signal == "units finalize":
_api.warn_deprecated(
"3.5", name=signal, obj_type="signal", alternative="units")
self._func_cid_map.setdefault(signal, {})
proxy = _weak_or_strong_ref(func, self._remove_proxy)
if proxy in self._func_cid_map[signal]:
Expand Down
9 changes: 0 additions & 9 deletions lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,15 +628,6 @@ def get_window_extent(self, renderer):
bbox = bbox.padded(ms)
return bbox

@Artist.axes.setter
def axes(self, ax):
# call the set method from the base-class property
Artist.axes.fset(self, ax)
if ax is not None:
for axis in ax._get_axis_map().values():
axis.callbacks._pickled_cids.add(
axis.callbacks.connect('units', self.recache_always))

def set_data(self, *args):
"""
Set the x and y data.
Expand Down

0 comments on commit 7d87722

Please sign in to comment.