@@ -1421,37 +1421,25 @@ def _select_layout_subplots_by_prefix(
14211421 else :
14221422 container_to_row_col = None
14231423
1424- # Natural sort keys so that xaxis20 is after xaxis3
1425- layout_keys = _natural_sort_strings (list (self .layout ))
1426-
1427- for k in layout_keys :
1428- if k .startswith (prefix ) and self .layout [k ] is not None :
1429-
1430- # Filter by row/col
1431- if (
1432- row is not None
1433- and container_to_row_col .get (k , (None , None , None ))[0 ] != row
1434- ):
1435- # row specified and this is not a match
1436- continue
1437- elif (
1438- col is not None
1439- and container_to_row_col .get (k , (None , None , None ))[1 ] != col
1440- ):
1441- # col specified and this is not a match
1442- continue
1443- elif (
1444- secondary_y is not None
1445- and container_to_row_col .get (k , (None , None , None ))[2 ]
1446- != secondary_y
1447- ):
1448- continue
1449-
1450- # Filter by selector
1451- if not self ._selector_matches (self .layout [k ], selector ):
1452- continue
1453-
1454- yield self .layout [k ]
1424+ layout_keys_filters = [
1425+ lambda k : k .startswith (prefix ) and self .layout [k ] is not None ,
1426+ lambda k : row is None
1427+ or container_to_row_col .get (k , (None , None , None ))[0 ] == row ,
1428+ lambda k : col is None
1429+ or container_to_row_col .get (k , (None , None , None ))[1 ] == col ,
1430+ lambda k : (
1431+ secondary_y is None
1432+ or container_to_row_col .get (k , (None , None , None ))[2 ] == secondary_y
1433+ ),
1434+ ]
1435+ layout_keys = reduce (
1436+ lambda last , f : filter (f , last ),
1437+ layout_keys_filters ,
1438+ # Natural sort keys so that xaxis20 is after xaxis3
1439+ _natural_sort_strings (list (self .layout )),
1440+ )
1441+ layout_objs = [self .layout [k ] for k in layout_keys ]
1442+ return self ._filter_by_selector (layout_objs , [], selector )
14551443
14561444 def _select_annotations_like (
14571445 self , prop , selector = None , row = None , col = None , secondary_y = None
0 commit comments