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

Skip to content

Commit b8e2e1b

Browse files
authored
Merge pull request #12527 from meeseeksmachine/auto-backport-of-pr-12461-on-v3.0.x
Backport PR #12461 on branch v3.0.x (FIX: make add_lines work with new colorbar)
2 parents 012c052 + 3dde05b commit b8e2e1b

File tree

7 files changed

+209
-195
lines changed

7 files changed

+209
-195
lines changed

lib/matplotlib/colorbar.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,13 +705,14 @@ def add_lines(self, levels, colors, linewidths, erase=True):
705705
removing any previously added lines.
706706
'''
707707
y = self._locate(levels)
708-
igood = (y < 1.001) & (y > -0.001)
708+
rtol = (self._y[-1] - self._y[0]) * 1e-10
709+
igood = (y < self._y[-1] + rtol) & (y > self._y[0] - rtol)
709710
y = y[igood]
710711
if cbook.iterable(colors):
711712
colors = np.asarray(colors)[igood]
712713
if cbook.iterable(linewidths):
713714
linewidths = np.asarray(linewidths)[igood]
714-
X, Y = np.meshgrid([0, 1], y)
715+
X, Y = np.meshgrid([self._y[0], self._y[-1]], y)
715716
if self.orientation == 'vertical':
716717
xy = np.stack([X, Y], axis=-1)
717718
else:
Binary file not shown.

0 commit comments

Comments
 (0)