@@ -1511,8 +1511,15 @@ def _make_verts(self, t, f1, f2, where):
15111511 t , f1 , f2 = np .broadcast_arrays (np .atleast_1d (t ), f1 , f2 , subok = True )
15121512
15131513 self ._bbox = transforms .Bbox .null ()
1514- self ._bbox .update_from_data_xy (self ._fix_pts_xy_order (np .concatenate ([
1515- np .stack ((t [where ], f [where ]), axis = - 1 ) for f in (f1 , f2 )])))
1514+ t_where = t .data [where ] if np .ma .isMA (t ) else t [where ]
1515+ f1_where = f1 .data [where ] if np .ma .isMA (f1 ) else f1 [where ]
1516+ f2_where = f2 .data [where ] if np .ma .isMA (f2 ) else f2 [where ]
1517+ n = len (t_where )
1518+ if n > 0 :
1519+ pts = np .empty ((2 * n , 2 )) # Preallocate and fill for speed
1520+ pts [:n , 0 ], pts [:n , 1 ] = t_where , f1_where
1521+ pts [n :, 0 ], pts [n :, 1 ] = t_where , f2_where
1522+ self ._bbox .update_from_data_xy (self ._fix_pts_xy_order (pts ))
15161523
15171524 return [
15181525 self ._make_verts_for_region (t , f1 , f2 , idx0 , idx1 )
@@ -1570,11 +1577,14 @@ def _make_verts_for_region(self, t, f1, f2, idx0, idx1):
15701577 start = t_slice [0 ], f2_slice [0 ]
15711578 end = t_slice [- 1 ], f2_slice [- 1 ]
15721579
1573- pts = np .concatenate ((
1574- np .asarray ([start ]),
1575- np .stack ((t_slice , f1_slice ), axis = - 1 ),
1576- np .asarray ([end ]),
1577- np .stack ((t_slice , f2_slice ), axis = - 1 )[::- 1 ]))
1580+ # Build polygon: start -> along f1 -> end -> back along f2 (reversed)
1581+ # Preallocate and fill for speed
1582+ n = len (t_slice )
1583+ pts = np .empty ((2 * n + 2 , 2 ))
1584+ pts [0 , :] = start
1585+ pts [1 :n + 1 , 0 ], pts [1 :n + 1 , 1 ] = t_slice , f1_slice
1586+ pts [n + 1 , :] = end
1587+ pts [n + 2 :, 0 ], pts [n + 2 :, 1 ] = t_slice [::- 1 ], f2_slice [::- 1 ]
15781588
15791589 return self ._fix_pts_xy_order (pts )
15801590
0 commit comments