@@ -7538,21 +7538,27 @@ def __init__(self, *args, foo, **kwargs):
7538
7538
self .foo = foo
7539
7539
7540
7540
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
- def test_twinning_subclass (twinning , axes_class , kw0 , kw1 ):
7547
- fig = plt .figure ()
7548
- classed_ax = fig .add_subplot (axes_class = axes_class , ** kw0 )
7549
- for k , v in kw0 .items ():
7550
- assert getattr (classed_ax , k ) == v
7551
-
7552
- twin = getattr (classed_ax , twinning )(axes_class = axes_class , ** kw1 )
7553
- assert type (twin ) is axes_class
7554
- for k , v in kw1 .items ():
7555
- assert getattr (twin , k ) == v
7541
+ def test_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
+ assert isinstance (twinx , SubclassAxes )
7546
+ assert twinx .foo == 1
7547
+ twiny = ax .twiny (axes_class = SubclassAxes , foo = 2 )
7548
+ assert isinstance (twiny , SubclassAxes )
7549
+ assert twiny .foo == 2
7550
+
7551
+
7552
+ def test_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
+ assert type (twinx ) is Axes
7560
+ twiny = ax .twiny ()
7561
+ assert type (twiny ) is Axes
7556
7562
7557
7563
7558
7564
def test_zero_linewidth ():
0 commit comments