E5F9 BUGS: in colorbar: divide-by-zero, and undesired masked array by efiring · Pull Request #8812 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ def _proportional_y(self):
y = y / (self._boundaries[-1] - self._boundaries[0])
else:
y = self.norm(self._boundaries.copy())
y = np.ma.filled(y, np.nan)
if self.extend == 'min':
# Exclude leftmost interval of y.
clen = y[-1] - y[1]
Expand All @@ -811,21 +812,22 @@ def _proportional_y(self):
clen = y[-2] - y[0]
automin = (y[1] - y[0]) / clen
automax = (y[-2] - y[-3]) / clen
else:
elif self.extend == 'both':
# Exclude leftmost and rightmost intervals in y.
clen = y[-2] - y[1]
automin = (y[2] - y[1]) / clen
automax = (y[-2] - y[-3]) / clen
extendlength = self._get_extension_lengths(self.extendfrac,
automin, automax,
default=0.05)
if self.extend in ('both', 'min', 'max'):
extendlength = self._get_extension_lengths(self.extendfrac,
automin, automax,
default=0.05)
if self.extend in ('both', 'min'):
y[0] = 0. - extendlength[0]
if self.extend in ('both', 'max'):
y[-1] = 1. + extendlength[1]
yi = y[self._inside]
norm = colors.Normalize(yi[0], yi[-1])
y[self._inside] = norm(yi)
y[self._inside] = np.ma.filled(norm(yi), np.nan)
return y

def _mesh(self):
Expand Down
0