Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 02078f0 commit 36d75b9Copy full SHA for 36d75b9
3 files changed
lib/matplotlib/collections.py
@@ -1511,13 +1511,13 @@ def _make_verts(self, t, f1, f2, where):
1511
t, f1, f2 = np.broadcast_arrays(np.atleast_1d(t), f1, f2, subok=True)
1512
1513
self._bbox = transforms.Bbox.null()
1514
- t_w = t.data[where] if np.ma.isMA(t) else t[where]
1515
- n = len(t_w)
+ t_where = t.data[where] if np.ma.isMA(t) else t[where]
+ n = len(t_where)
1516
if n > 0:
1517
- pts = np.empty((2 * n, 2))
1518
- pts[:n, 0] = t_w
+ pts = np.empty((2 * n, 2)) # Preallocate and fill for speed
+ pts[:n, 0] = t_where
1519
pts[:n, 1] = f1.data[where] if np.ma.isMA(f1) else f1[where]
1520
- pts[n:, 0] = t_w
+ pts[n:, 0] = t_where
1521
pts[n:, 1] = f2.data[where] if np.ma.isMA(f2) else f2[where]
1522
self._bbox.update_from_data_xy(self._fix_pts_xy_order(pts))
1523
lib/matplotlib/lines.py
@@ -714,6 +714,7 @@ def recache(self, always=False):
714
vertices = self._xy
715
else:
716
steps = step_func(*self._xy.T)
717
+ # Preallocate and fill for speed
718
vertices = np.empty((steps.shape[1], 2))
719
vertices[:, 0] = steps[0]
720
vertices[:, 1] = steps[1]
@@ -735,6 +736,7 @@ def _transform_path(self, subslice=None):
735
736
vertices = self._xy[subslice]
737
738
steps = step_func(*self._xy[subslice, :].T)
739
740
741
742
lib/matplotlib/transforms.py
@@ -909,7 +909,7 @@ def update_from_path(self, path, ignore=None, updatex=True, updatey=True):
909
minx = np.min(x, initial=np.inf)
910
points[0, 0] = min(points[0, 0], minx)
911
points[1, 0] = max(points[1, 0], np.max(x, initial=-np.inf))
912
- if minx > 0:
+ if minx > 0: # Fast path for all-positive x values
913
minpos[0] = min(minpos[0], minx)
914
915
minpos[0] = min(minpos[0], np.min(x[x > 0], initial=np.inf))
@@ -918,7 +918,7 @@ def update_from_path(self, path, ignore=None, updatex=True, updatey=True):
918
miny = np.min(y, initial=np.inf)
919
points[0, 1] = min(points[0, 1], miny)
920
points[1, 1] = max(points[1, 1], np.max(y, initial=-np.inf))
921
- if miny > 0:
+ if miny > 0: # Fast path for all-positive y values
922
minpos[1] = min(minpos[1], miny)
923
924
minpos[1] = min(minpos[1], np.min(y[y > 0], initial=np.inf))
0 commit comments