@@ -4592,7 +4592,7 @@ def _make_twin_axes(self, *args, **kwargs):
4592
4592
self ._twinned_axes .join (self , twin )
4593
4593
return twin
4594
4594
4595
- def twinx (self ):
4595
+ def twinx (self , axes_class = None , ** kwargs ):
4596
4596
"""
4597
4597
Create a twin Axes sharing the xaxis.
4598
4598
@@ -4602,6 +4602,22 @@ def twinx(self):
4602
4602
Axes. To ensure that the tick marks of both y-axes align, see
4603
4603
`~matplotlib.ticker.LinearLocator`.
4604
4604
4605
+ Parameters
4606
+ ----------
4607
+ axes_class : subclass type of `~.axes.Axes`, optional
4608
+ The `.axes.Axes` subclass that is instantiated. This parameter
4609
+ is incompatible with *projection* and *polar*. See
4610
+ :ref:`axisartist_users-guide-index` for examples.
4611
+
4612
+ By default, `~.axes.Axes` is used.
4613
+
4614
+ .. versionadded:: 3.11
4615
+
4616
+ kwargs : dict
4617
+ The keyword arguments passed to `.Figure.add_subplot` or `.Figure.add_axes`.
4618
+
4619
+ .. versionadded:: 3.11
4620
+
4605
4621
Returns
4606
4622
-------
4607
4623
Axes
@@ -4612,7 +4628,9 @@ def twinx(self):
4612
4628
For those who are 'picking' artists while using twinx, pick
4613
4629
events are only called for the artists in the top-most Axes.
4614
4630
"""
4615
- ax2 = self ._make_twin_axes (sharex = self )
4631
+ if axes_class :
4632
+ kwargs ["axes_class" ] = axes_class
4633
+ ax2 = self ._make_twin_axes (sharex = self , ** kwargs )
4616
4634
ax2 .yaxis .tick_right ()
4617
4635
ax2 .yaxis .set_label_position ('right' )
4618
4636
ax2 .yaxis .set_offset_position ('right' )
@@ -4623,7 +4641,7 @@ def twinx(self):
4623
4641
ax2 .xaxis .units = self .xaxis .units
4624
4642
return ax2
4625
4643
4626
- def twiny (self ):
4644
+ def twiny (self , axes_class = None , ** kwargs ):
4627
4645
"""
4628
4646
Create a twin Axes sharing the yaxis.
4629
4647
@@ -4633,6 +4651,22 @@ def twiny(self):
4633
4651
To ensure that the tick marks of both x-axes align, see
4634
4652
`~matplotlib.ticker.LinearLocator`.
4635
4653
4654
+ Parameters
4655
+ ----------
4656
+ axes_class : subclass type of `~.axes.Axes`, optional
4657
+ The `.axes.Axes` subclass that is instantiated. This parameter
4658
+ is incompatible with *projection* and *polar*. See
4659
+ :ref:`axisartist_users-guide-index` for examples.
4660
+
4661
+ By default, `~.axes.Axes` is used.
4662
+
4663
+ .. versionadded:: 3.11
4664
+
4665
+ kwargs : dict
4666
+ The keyword arguments passed to `.Figure.add_subplot` or `.Figure.add_axes`.
4667
+
4668
+ .. versionadded:: 3.11
4669
+
4636
4670
Returns
4637
4671
-------
4638
4672
Axes
@@ -4643,7 +4677,9 @@ def twiny(self):
4643
4677
For those who are 'picking' artists while using twiny, pick
4644
4678
events are only called for the artists in the top-most Axes.
4645
4679
"""
4646
- ax2 = self ._make_twin_axes (sharey = self )
4680
+ if axes_class :
4681
+ kwargs ["axes_class" ] = axes_class
4682
+ ax2 = self ._make_twin_axes (sharey = self , ** kwargs )
4647
4683
ax2 .xaxis .tick_top ()
4648
4684
ax2 .xaxis .set_label_position ('top' )
4649
4685
ax2 .set_autoscaley_on (self .get_autoscaley_on ())
0 commit comments