@@ -1355,29 +1355,33 @@ def test_legend_span_inference_with_multi_panels(
13551355def test_legend_best_axis_selection_right_left ():
13561356 fig , axs = uplt .subplots (nrows = 1 , ncols = 3 )
13571357 axs .plot ([0 , 1 ], [0 , 1 ], label = "line" )
1358- ref = [axs [0 , 0 ], axs [0 , 2 ]]
1358+ left = _anchor_axis (axs [0 , 0 ])
1359+ right = _anchor_axis (axs [0 , 2 ])
1360+ ref = [left , right ]
13591361
13601362 fig .legend (ref = ref , loc = "r" , rows = 1 )
1361- assert len (axs [ 0 , 2 ] ._panel_dict ["right" ]) == 1
1362- assert len (axs [ 0 , 0 ] ._panel_dict ["right" ]) == 0
1363+ assert len (right ._panel_dict ["right" ]) == 1
1364+ assert len (left ._panel_dict ["right" ]) == 0
13631365
13641366 fig .legend (ref = ref , loc = "l" , rows = 1 )
1365- assert len (axs [ 0 , 0 ] ._panel_dict ["left" ]) == 1
1366- assert len (axs [ 0 , 2 ] ._panel_dict ["left" ]) == 0
1367+ assert len (left ._panel_dict ["left" ]) == 1
1368+ assert len (right ._panel_dict ["left" ]) == 0
13671369
13681370
13691371def test_legend_best_axis_selection_top_bottom ():
13701372 fig , axs = uplt .subplots (nrows = 2 , ncols = 1 )
13711373 axs .plot ([0 , 1 ], [0 , 1 ], label = "line" )
1372- ref = [axs [0 , 0 ], axs [1 , 0 ]]
1374+ top = _anchor_axis (axs [0 , 0 ])
1375+ bottom = _anchor_axis (axs [1 , 0 ])
1376+ ref = [top , bottom ]
13731377
13741378 fig .legend (ref = ref , loc = "t" , cols = 1 )
1375- assert len (axs [ 0 , 0 ] ._panel_dict ["top" ]) == 1
1376- assert len (axs [ 1 , 0 ] ._panel_dict ["top" ]) == 0
1379+ assert len (top ._panel_dict ["top" ]) == 1
1380+ assert len (bottom ._panel_dict ["top" ]) == 0
13771381
13781382 fig .legend (ref = ref , loc = "b" , cols = 1 )
1379- assert len (axs [ 1 , 0 ] ._panel_dict ["bottom" ]) == 1
1380- assert len (axs [ 0 , 0 ] ._panel_dict ["bottom" ]) == 0
1383+ assert len (bottom ._panel_dict ["bottom" ]) == 1
1384+ assert len (top ._panel_dict ["bottom" ]) == 0
13811385
13821386
13831387def test_legend_span_decode_fallback (monkeypatch ):
0 commit comments