8000 Merge pull request #21686 from jklymak/fix-colorbar-hline · matplotlib/matplotlib@3980561 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3980561

Browse files
authored
Merge pull request #21686 from jklymak/fix-colorbar-hline
FIX: colorbar for horizontal contours
2 parents 54aa92a + 5525bbe commit 3980561

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

lib/matplotlib/colorbar.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,6 @@ def add_lines(self, *args, **kwargs):
790790
xy[[2, 3], 1] += fac
791791
# back to axes units...
792792
xy = self.ax.transAxes.inverted().transform(inches.transform(xy))
793-
if self.orientation == 'horizontal':
794-
xy = xy.T
795793
col.set_clip_path(mpath.Path(xy, closed=True),
796794
self.ax.transAxes)
797795
self.ax.add_collection(col)
Loading

lib/matplotlib/tests/test_colorbar.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ def test_colorbar_positioning(use_gridspec):
185185
anchor=(0.8, 0.5), shrink=0.6, use_gridspec=use_gridspec)
186186

187187

188+
@image_comparison(['contour_colorbar.png'], remove_text=True)
189+
def test_contour_colorbar():
190+
fig, ax = plt.subplots(figsize=(4, 2))
191+
data = np.arange(1200).reshape(30, 40) - 500
192+
levels = np.array([0, 200, 400, 600, 800, 1000, 1200]) - 500
193+
194+
CS = ax.contour(data, levels=levels, extend='both')
195+
fig.colorbar(CS, orientation='horizontal', extend='both')
196+
fig.colorbar(CS, orientation='vertical')
197+
198+
188199
@image_comparison(['cbar_with_subplots_adjust.png'], remove_text=True,
189200
savefig_kwarg={'dpi': 40})
190201
def test_gridspec_make_colorbar():

0 commit comments

Comments
 (0)
0