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

Skip to content

Commit fbd0fba

Browse files
authored
Merge pull request #12461 from jklymak/fix-cbar-addlines
FIX: make add_lines work with new colorbar
2 parents b424c85 + 389cf07 commit fbd0fba

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
@@ -704,13 +704,14 @@ def add_lines(self, levels, colors, linewidths, erase=True):
704704
removing any previously added lines.
705705
'''
706706
y = self._locate(levels)
707-
igood = (y < 1.001) & (y > -0.001)
707+
rtol = (self._y[-1] - self._y[0]) * 1e-10
708+
igood = (y < self._y[-1] + rtol) & (y > self._y[0] - rtol)
708709
y = y[igood]
709710
if np.iterable(colors):
710711
colors = np.asarray(colors)[igood]
711712
if np.iterable(linewidths):
712713
linewidths = np.asarray(linewidths)[igood]
713-
X, Y = np.meshgrid([0, 1], y)
714+
X, Y = np.meshgrid([self._y[0], self._y[-1]], y)
714715
if self.orientation == 'vertical':
715716
xy = np.stack([X, Y], axis=-1)
716717
else:
Binary file not shown.

0 commit comments

Comments
 (0)