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):
4441
4441
self .yaxis .tick_left ()
4442
4442
ax2 .xaxis .set_visible (False )
4443
4443
ax2 .patch .set_visible (False )
4444
+ ax2 .xaxis .units = self .xaxis .units
4444
4445
return ax2
4445
4446
4446
4447
def twiny (self ):
@@ -4470,6 +4471,7 @@ def twiny(self):
4470
4471
self .xaxis .tick_bottom ()
4471
4472
ax2 .yaxis .set_visible (False )
4472
4473
ax2 .patch .set_visible (False )
4474
+ ax2 .yaxis .units = self .yaxis .units
4473
4475
return ax2
4474
4476
4475
4477
def get_shared_x_axes (self ):
Original file line number Diff line number Diff line change @@ -376,6 +376,23 @@ def test_twinx_cla():
376
376
assert ax .yaxis .get_visible ()
377
377
378
378
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
+
379
396
@pytest .mark .parametrize ('twin' , ('x' , 'y' ))
380
397
@check_figures_equal (extensions = ['png' ], tol = 0.19 )
381
398
def test_twin_logscale (fig_test , fig_ref , twin ):
You can’t perform that action at this time.
0 commit comments