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

Commit0db9c6c

Browse files
committed
MNT: Remove deprecated axes kwargs collision detection
In Matplotlib 2.1, the behavior of reusing existing axes whencreated with the same arguments was deprecated (seematplotlib#9037). Thisbehavior is now removed.The behavior of the functions to create new axes (`pyplot.axes`,`pyplot.subplot`, `figure.Figure.add_axes`,`figure.Figure.add_subplot`) has changed. In the past, thesefunctions would detect if you were attempting to create Axes withthe same keyword arguments as already-existing axes in the currentfigure, and if so, they would return the existing Axes. Now, thesefunctions will always create new Axes. A special exception is`pyplot.subplot`, which will reuse any existing subplot with amatching subplot spec. However, if there is a subplot with amatching subplot spec, then that subplot will be returned, even ifthe keyword arguments with which it was created differ.Correspondingly, the behavior of the functions to get the currentAxes (`pyplot.gca`, `figure.Figure.gca`) has changed. In the past,these functions accepted keyword arguments. If the keywordarguments matched an already-existing Axes, then that Axes wouldbe returned, otherwise new Axes would be created with thosekeyword arguments. Now, the keyword arguments are only consideredif there are no axes at all in the current figure. In a futurerelease, these functions will not accept keyword arguments at all.Fixesmatplotlib#18832.
1 parent7d64909 commit0db9c6c

File tree

9 files changed

+246
-286
lines changed

9 files changed

+246
-286
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``pyplot.gca()``, ``Figure.gca``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Passing keyword arguments to `.pyplot.gca` or `.figure.Figure.gca` will not be
5+
supported in a future release.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Changes to behavior of Axes creation methods (``gca()``, ``add_axes()``, ``add_subplot()``)
2+
-------------------------------------------------------------------------------------------
3+
4+
The behavior of the functions to create new axes (`.pyplot.axes`,
5+
`.pyplot.subplot`, `.figure.Figure.add_axes`,
6+
`.figure.Figure.add_subplot`) has changed. In the past, these functions would
7+
detect if you were attempting to create Axes with the same keyword arguments as
8+
already-existing axes in the current figure, and if so, they would return the
9+
existing Axes. Now, these functions will always create new Axes. A special
10+
exception is `.pyplot.subplot`, which will reuse any existing subplot with a
11+
matching subplot spec. However, if there is a subplot with a matching subplot
12+
spec, then that subplot will be returned, even if the keyword arguments with
13+
which it was created differ.
14+
15+
Correspondingly, the behavior of the functions to get the current Axes
16+
(`.pyplot.gca`, `.figure.Figure.gca`) has changed. In the past, these functions
17+
accepted keyword arguments. If the keyword arguments matched an
18+
already-existing Axes, then that Axes would be returned, otherwise new Axes
19+
would be created with those keyword arguments. Now, the keyword arguments are
20+
only considered if there are no axes at all in the current figure. In a future
21+
release, these functions will not accept keyword arguments at all.

‎lib/matplotlib/axes/_subplots.py‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
importfunctools
2-
importuuid
32

43
frommatplotlibimport_api,docstring
54
importmatplotlib.artistasmartist
@@ -142,16 +141,7 @@ def _make_twin_axes(self, *args, **kwargs):
142141
# which currently uses this internal API.
143142
ifkwargs["sharex"]isnotselfandkwargs["sharey"]isnotself:
144143
raiseValueError("Twinned Axes may share only one axis")
145-
# The dance here with label is to force add_subplot() to create a new
146-
# Axes (by passing in a label never seen before). Note that this does
147-
# not affect plot reactivation by subplot() as twin axes can never be
148-
# reactivated by subplot().
149-
sentinel=str(uuid.uuid4())
150-
real_label=kwargs.pop("label",sentinel)
151-
twin=self.figure.add_subplot(
152-
self.get_subplotspec(),*args,label=sentinel,**kwargs)
153-
ifreal_labelisnotsentinel:
154-
twin.set_label(real_label)
144+
twin=self.figure.add_subplot(self.get_subplotspec(),*args,**kwargs)
155145
self.set_adjustable('datalim')
156146
twin.set_adjustable('datalim')
157147
self._twinned_axes.join(self,twin)

‎lib/matplotlib/cbook/__init__.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,9 @@ def __len__(self):
606606
def__getitem__(self,ind):
607607
returnself._elements[ind]
608608

609+
defas_list(self):
610+
returnlist(self._elements)
611+
609612
defforward(self):
610613
"""Move the position forward and return the current element."""
611614
self._pos=min(self._pos+1,len(self._elements)-1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp