File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -4441,6 +4441,7 @@ def twinx(self):
44414441 self .yaxis .tick_left ()
44424442 ax2 .xaxis .set_visible (False )
44434443 ax2 .patch .set_visible (False )
4444+ ax2 .xaxis .units = self .xaxis .units
44444445 return ax2
44454446
44464447 def twiny (self ):
@@ -4470,6 +4471,7 @@ def twiny(self):
44704471 self .xaxis .tick_bottom ()
44714472 ax2 .yaxis .set_visible (False )
44724473 ax2 .patch .set_visible (False )
4474+ ax2 .yaxis .units = self .yaxis .units
44734475 return ax2
44744476
44754477 def get_shared_x_axes (self ):
Original file line number Diff line number Diff line change @@ -376,6 +376,23 @@ def test_twinx_cla():
376376 assert ax .yaxis .get_visible ()
377377
378378
379+ @pytest .mark .parametrize ('twin' , ('x' , 'y' ))
380+ def test_twin_units (twin ):
381+ axis_name = f'{ twin } axis'
382+ twin_func = f'twin{ twin } '
383+
384+ a = ['0' , '1' ]
385+ b = ['a' , 'b' ]
386+
387+ fig = Figure ()
388+ ax1 = fig .subplots ()
389+ ax1 .plot (a , b )
390+ assert getattr (ax1 , axis_name ).units is not None
391+ ax2 = getattr (ax1 , twin_func )()
392+ assert getattr (ax2 , axis_name ).units is not None
393+ assert getattr (ax2 , axis_name ).units is getattr (ax1 , axis_name ).units
394+
395+
379396@pytest .mark .parametrize ('twin' , ('x' , 'y' ))
380397@check_figures_equal (extensions = ['png' ], tol = 0.19 )
381398def test_twin_logscale (fig_test , fig_ref , twin ):
You can’t perform that action at this time.
0 commit comments