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

Skip to content

Commit d0ed04c

Browse files
eendebakptclaude
andcommitted
move clip-state propagation onto Tick._configure_for_axis
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent e80c08e commit d0ed04c

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

lib/matplotlib/axis.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,18 @@ def set_clip_path(self, path, transform=None):
244244
self.gridline.set_clip_path(path, transform)
245245
self.stale = True
246246

247+
def _configure_for_axis(self, axis):
248+
"""
249+
Copy the Axis clip state onto this Tick and its gridline.
250+
251+
Used by `_LazyTickList` to stamp clip state set via
252+
`Axis.set_clip_path` onto a lazily-materialized Tick.
253+
"""
254+
for artist in (self, self.gridline):
255+
artist.clipbox = axis.clipbox
256+
artist._clippath = axis._clippath
257+
artist._clipon = axis._clipon
258+
247259
def contains(self, mouseevent):
248260
"""
249261
Test whether the mouse event occurred in the Tick marks.
@@ -598,7 +610,7 @@ def __get__(self, instance, owner):
598610
else instance._minor_tick_kw)
599611
if tick_kw:
600612
tick._apply_params(**tick_kw)
601-
instance._propagate_axis_state_to_tick(tick)
613+
tick._configure_for_axis(instance)
602614
tick_list.append(tick)
603615
setattr(instance, attr, tick_list)
604616
return tick_list
@@ -713,7 +725,7 @@ def __init__(self, axes, *, pickradius=15, clear=True):
713725
# materialization would have seen. Kept separate from
714726
# _major_tick_kw/_minor_tick_kw, which hold user-provided
715727
# set_tick_params() overrides rather than ambient rcParams. See
716-
# _propagate_axis_state_to_tick() for the clip-state counterpart.
728+
# Tick._configure_for_axis() for the clip-state counterpart.
717729
self._tick_rcParams = None
718730

719731
if clear:
@@ -889,22 +901,6 @@ def get_children(self):
889901
return [self.label, self.offsetText,
890902
*self.get_major_ticks(), *self.get_minor_ticks()]
891903

892-
def _propagate_axis_state_to_tick(self, tick):
893-
"""
894-
Copy Axis clip state onto a lazily-created Tick.
895-
896-
`Axis.set_clip_path` can run before any Tick exists, so the clip
897-
stored on the Axis must be re-stamped onto the first Tick when
898-
it materializes (only the Tick itself and its gridline are
899-
clipped, matching `Tick.set_clip_path`). Per-Artist rcParams
900-
like ``path.sketch`` / ``path.effects`` are handled by the
901-
rcParams restore in `_LazyTickList.__get__`, not here.
902-
"""
903-
for artist in (tick, tick.gridline):
904-
artist.clipbox = self.clipbox
905-
artist._clippath = self._clippath
906-
artist._clipon = self._clipon
907-
908904
def _reset_major_tick_kw(self):
909905
self._major_tick_kw.clear()
910906
self._major_tick_kw['gridOn'] = (

0 commit comments

Comments
 (0)