@@ -7677,6 +7677,14 @@ def table(self, **kwargs):
76777677 """
76787678 return mtable .table (self , ** kwargs )
76797679
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+
76807688 def twinx (self ):
76817689 """
76827690 Call signature::
@@ -7693,8 +7701,7 @@ def twinx(self):
76937701 events are only called for the artists in the top-most axes.
76947702 """
76957703
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 )
76987705 ax2 .yaxis .tick_right ()
76997706 ax2 .yaxis .set_label_position ('right' )
77007707 ax2 .yaxis .set_offset_position ('right' )
@@ -7718,8 +7725,7 @@ def twiny(self):
77187725 events are only called for the artists in the top-most axes.
77197726 """
77207727
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 )
77237729 ax2 .xaxis .tick_top ()
77247730 ax2 .xaxis .set_label_position ('top' )
77257731 self .xaxis .tick_bottom ()
@@ -8899,6 +8905,13 @@ def label_outer(self):
88998905 label .set_visible (firstcol )
89008906
89018907
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+
89028915
89038916_subplot_classes = {}
89048917def subplot_class_factory (axes_class = None ):
0 commit comments