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

Skip to content

Commit 3dde05b

Browse files
dstansbyMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #12461: FIX: make add_lines work with new colorbar
1 parent 012c052 commit 3dde05b

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)