Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fa79e3d

Browse files
committed
Add guard in autoscale against empty arrays.
1 parent b637f41 commit fa79e3d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/colors.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,8 +1368,14 @@ def inverse(self, value):
13681368
def autoscale(self, A):
13691369
"""Set *vmin*, *vmax* to min, max of *A*."""
13701370
A = np.asanyarray(A)
1371-
self.vmin = A.min()
1372-
self.vmax = A.max()
1371+
# Ensure that A has non-zero size to compute min/max.
1372+
# Otherwise put in filler values.
1373+
if A.size:
1374+
self.vmin = A.min()
1375+
self.vmax = A.max()
1376+
else:
1377+
self.vmin = 0.0
1378+
self.vmax = 0.0
13731379

13741380
def autoscale_None(self, A):
13751381
"""If vmin or vmax are not set, use the min/max of *A* to set them."""

0 commit comments

Comments
 (0)