Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8810536

Browse files
committed
Init axes._children early enough to avoid need for some getattr calls.
1 parentccbd641 commit8810536

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

‎lib/matplotlib/axes/_base.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,8 @@ def __init__(self, fig,
665665
self.set_box_aspect(box_aspect)
666666
self._axes_locator=None# Optionally set via update(kwargs).
667667

668+
self._children= []
669+
668670
# placeholder for any colorbars added that use this Axes.
669671
# (see colorbar.py):
670672
self._colorbars= []
@@ -1078,7 +1080,7 @@ def _update_transScale(self):
10781080
self.transScale.set(
10791081
mtransforms.blended_transform_factory(
10801082
self.xaxis.get_transform(),self.yaxis.get_transform()))
1081-
forlineingetattr(self,"_children", []):# Not set during init.
1083+
forlineinself._children:
10821084
ifnotisinstance(line,mlines.Line2D):
10831085
continue
10841086
try:
@@ -2936,22 +2938,15 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
29362938

29372939
x_stickies=y_stickies=np.array([])
29382940
ifself.use_sticky_edges:
2939-
# Only iterate over Axes and artists if needed. The check for
2940-
# ``hasattr(ax, "_children")`` is necessary because this can be
2941-
# called very early in the Axes init process (e.g., for twin Axes)
2942-
# when these attributes don't even exist yet, in which case
2943-
# `get_children` would raise an AttributeError.
29442941
ifself._xmarginandscalexandself.get_autoscalex_on():
29452942
x_stickies=np.sort(np.concatenate([
29462943
artist.sticky_edges.x
29472944
foraxinself._shared_axes["x"].get_siblings(self)
2948-
ifhasattr(ax,"_children")
29492945
forartistinax.get_children()]))
29502946
ifself._ymarginandscaleyandself.get_autoscaley_on():
29512947
y_stickies=np.sort(np.concatenate([
29522948
artist.sticky_edges.y
29532949
foraxinself._shared_axes["y"].get_siblings(self)
2954-
ifhasattr(ax,"_children")
29552950
forartistinax.get_children()]))
29562951
ifself.get_xscale()=='log':
29572952
x_stickies=x_stickies[x_stickies>0]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp