@@ -7677,6 +7677,14 @@ def table(self, **kwargs):
7677
7677
"""
7678
7678
return mtable .table (self , ** kwargs )
7679
7679
7680
+ def _make_twin_axes (self , * kl , ** kwargs ):
7681
+ """
7682
+ make a twinx axes of self. This is used for twinx and twiny.
7683
+ """
7684
+ ax2 = self .figure .add_axes (self .get_position (True ), * kl , ** kwargs )
7685
+ return ax2
7686
+
7687
+
7680
7688
def twinx (self ):
7681
7689
"""
7682
7690
Call signature::
@@ -7693,8 +7701,7 @@ def twinx(self):
7693
7701
events are only called for the artists in the top-most axes.
7694
7702
"""
7695
7703
7696
- ax2 = self .figure .add_axes (self .get_position (True ), sharex = self ,
7697
- frameon = False )
7704
+ ax2 = self ._make_twin_axes (sharex = self , frameon = False )
7698
7705
ax2 .yaxis .tick_right ()
7699
7706
ax2 .yaxis .set_label_position ('right' )
7700
7707
ax2 .yaxis .set_offset_position ('right' )
@@ -7718,8 +7725,7 @@ def twiny(self):
7718
7725
events are only called for the artists in the top-most axes.
7719
7726
"""
7720
7727
7721
- ax2 = self .figure .add_axes (self .get_position (True ), sharey = self ,
7722
- frameon = False )
7728
+ ax2 = self ._make_twin_axes (sharey = self , frameon = False )
7723
7729
ax2 .xaxis .tick_top ()
7724
7730
ax2 .xaxis .set_label_position ('top' )
7725
7731
self .xaxis .tick_bottom ()
@@ -8899,6 +8905,13 @@ def label_outer(self):
8899
8905
label .set_visible (firstcol )
8900
8906
8901
8907
8908
+ def _make_twin_axes (self , * kl , ** kwargs ):
8909
+ """
8910
+ make a twinx axes of self. This is used for twinx and twiny.
8911
+ """
8912
+ ax2 = self .figure .add_subplot (self .get_subplotspec (), * kl , ** kwargs )
8913
+ return ax2
8914
+
8902
8915
8903
8916
_subplot_classes = {}
8904
8917
def subplot_class_factory (axes_class = None ):
0 commit comments