8000 Merge pull request #21691 from meeseeksmachine/auto-backport-of-pr-21… · matplotlib/matplotlib@77d2159 · GitHub
[go: up one dir, main page]

Skip to content

Commit 77d2159

Browse files
authored
Merge pull request #21691 from meeseeksmachine/auto-backport-of-pr-21686-on-v3.5.x
Backport PR #21686 on branch v3.5.x (FIX: colorbar for horizontal contours)
2 parents 2b124c7 + a6f9d82 commit 77d2159

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
@@ -783,8 +783,6 @@ def add_lines(self, *args, **kwargs):
783783
xy[[2, 3], 1] += fac
784784
# back to axes units...
785785
xy = self.ax.transAxes.inverted().transform(inches.transform(xy))
786-
if self.orientation == 'horizontal':
787-
xy = xy.T
788786
col.set_clip_path(mpath.Path(xy, closed=True),
789787
self.ax.transAxes)
790788
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