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

Commitecb384e

Browse files
cmp0xfftimhoffm
andcommitted
1 parente9ce871 commitecb384e

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

‎lib/matplotlib/axes/_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4613,6 +4613,8 @@ def twinx(self, axes_class=None, **kwargs):
46134613
is incompatible with *projection* and *polar*. See
46144614
:ref:`axisartist_users-guide-index` for examples.
46154615
4616+
By default, `~.axes.Axes` is used.
4617+
46164618
kwargs : dict
46174619
The keyword arguments passed to ``add_subplot()`` or ``add_axes()``.
46184620
@@ -4656,6 +4658,8 @@ def twiny(self, axes_class=None, **kwargs):
46564658
is incompatible with *projection* and *polar*. See
46574659
:ref:`axisartist_users-guide-index` for examples.
46584660
4661+
By default, `~.axes.Axes` is used.
4662+
46594663
kwargs : dict
46604664
The keyword arguments passed to ``add_subplot()`` or ``add_axes()``.
46614665

‎lib/matplotlib/tests/test_axes.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7538,21 +7538,27 @@ def __init__(self, *args, foo, **kwargs):
75387538
self.foo=foo
75397539

75407540

7541-
@pytest.mark.parametrize("twinning", ["twinx","twiny"])
7542-
@pytest.mark.parametrize(("axes_class","kw0","kw1"), [
7543-
(Axes, {}, {}),
7544-
(SubclassAxes, {"foo":0}, {"foo":1}),
7545-
])
7546-
deftest_twinning_subclass(twinning,axes_class,kw0,kw1):
7547-
fig=plt.figure()
7548-
classed_ax=fig.add_subplot(axes_class=axes_class,**kw0)
7549-
fork,vinkw0.items():
7550-
assertgetattr(classed_ax,k)==v
7551-
7552-
twin=getattr(classed_ax,twinning)(axes_class=axes_class,**kw1)
7553-
asserttype(twin)isaxes_class
7554-
fork,vinkw1.items():
7555-
assertgetattr(twin,k)==v
7541+
deftest_twinning_with_axes_class():
7542+
"""Check that twinx/y(axes_class=...) gives the appropriate class."""
7543+
_,ax=plt.subplots()
7544+
twinx=ax.twinx(axes_class=SubclassAxes,foo=1)
7545+
assertisinstance(twinx,SubclassAxes)
7546+
asserttwinx.foo==1
7547+
twiny=ax.twiny(axes_class=SubclassAxes,foo=2)
7548+
assertisinstance(twiny,SubclassAxes)
7549+
asserttwiny.foo==2
7550+
7551+
7552+
deftest_twinning_default_axes_class():
7553+
"""
7554+
Check that the default class for twinx/y() is Axes,
7555+
even if the original is an Axes subclass.
7556+
"""
7557+
_,ax=plt.subplots(subplot_kw=dict(axes_class=SubclassAxes,foo=1))
7558+
twinx=ax.twinx()
7559+
asserttype(twinx)isAxes
7560+
twiny=ax.twiny()
7561+
asserttype(twiny)isAxes
75567562

75577563

75587564
deftest_zero_linewidth():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp