@@ -4596,7 +4596,7 @@ def _make_twin_axes(self, *args, **kwargs):
4596
4596
self ._twinned_axes .join (self ,twin )
4597
4597
return twin
4598
4598
4599
- def twinx (self ,** kwargs ):
4599
+ def twinx (self ,axes_class = None , ** kwargs ):
4600
4600
"""
4601
4601
Create a twin Axes sharing the xaxis.
4602
4602
@@ -4608,6 +4608,11 @@ def twinx(self, **kwargs):
4608
4608
4609
4609
Parameters
4610
4610
----------
4611
+ axes_class : subclass type of `~.axes.Axes`, optional
4612
+ The `.axes.Axes` subclass that is instantiated. This parameter
4613
+ is incompatible with *projection* and *polar*. See
4614
+ :ref:`axisartist_users-guide-index` for examples.
4615
+
4611
4616
kwargs : dict
4612
4617
The keyword arguments passed to ``add_subplot()`` or ``add_axes()``.
4613
4618
@@ -4621,9 +4626,9 @@ def twinx(self, **kwargs):
4621
4626
For those who are 'picking' artists while using twinx, pick
4622
4627
events are only called for the artists in the top-most Axes.
4623
4628
"""
4624
- if not { "projection" , "polar" , " axes_class" }. intersection ( kwargs ) :
4625
- kwargs ["axes_class" ]= type ( self )
4626
- ax2 = self ._make_twin_axes (sharex = self ,axes_class = type ( self ), ** kwargs )
4629
+ if axes_class :
4630
+ kwargs ["axes_class" ]= axes_class
4631
+ ax2 = self ._make_twin_axes (sharex = self ,** kwargs )
4627
4632
ax2 .yaxis .tick_right ()
4628
4633
ax2 .yaxis .set_label_position ('right' )
4629
4634
ax2 .yaxis .set_offset_position ('right' )
@@ -4634,7 +4639,7 @@ def twinx(self, **kwargs):
4634
4639
ax2 .xaxis .units = self .xaxis .units
4635
4640
return ax2
4636
4641
4637
- def twiny (self ,** kwargs ):
4642
+ def twiny (self ,axes_class = None , ** kwargs ):
4638
4643
"""
4639
4644
Create a twin Axes sharing the yaxis.
4640
4645
@@ -4646,6 +4651,11 @@ def twiny(self, **kwargs):
4646
4651
4647
4652
Parameters
4648
4653
----------
4654
+ axes_class : subclass type of `~.axes.Axes`, optional
4655
+ The `.axes.Axes` subclass that is instantiated. This parameter
4656
+ is incompatible with *projection* and *polar*. See
4657
+ :ref:`axisartist_users-guide-index` for examples.
4658
+
4649
4659
kwargs : dict
4650
4660
The keyword arguments passed to ``add_subplot()`` or ``add_axes()``.
4651
4661
@@ -4659,9 +4669,9 @@ def twiny(self, **kwargs):
4659
4669
For those who are 'picking' artists while using twiny, pick
4660
4670
events are only called for the artists in the top-most Axes.
4661
4671
"""
4662
- if not { "projection" , "polar" , " axes_class" }. intersection ( kwargs ) :
4663
- kwargs ["axes_class" ]= type ( self )
4664
- ax2 = self ._make_twin_axes (sharey = self ,axes_class = type ( self ), ** kwargs )
4672
+ if axes_class :
4673
+ kwargs ["axes_class" ]= axes_class
4674
+ ax2 = self ._make_twin_axes (sharey = self ,** kwargs )
4665
4675
ax2 .xaxis .tick_top ()
4666
4676
ax2 .xaxis .set_label_position ('top' )
4667
4677
ax2 .set_autoscaley_on (self .get_autoscaley_on ())