8000 FIX: colorbar for horizontal contours by jklymak · Pull Request #21686 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: colorbar for horizontal contours #21686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2021

Conversation

jklymak
Copy link
Member
@jklymak jklymak commented Nov 20, 2021

PR Summary

Closes #21683

import matplotlib.pyplot as plt
import matplotlib.cm as mpcm
import matplotlib.colors as mpcolors
import numpy as np
from matplotlib import colorbar

fig, ax = plt.subplots()
CS = ax.contour([[0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0]], levels=np.arange(0,1,0.2))
cb = fig.colorbar(CS, orientation='horizontal')
cb = fig.colorbar(CS, orientation='vertical')
#cb.add_lines(CS)
plt.show()

fails on master. Fixed here, with a new test. For some reason we were transposing xy twice and horizontal colorbars do not have the test coverage they should.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@@ -790,8 +790,6 @@ def add_lines(self, *args, **kwargs):
xy[[2, 3], 1] += fac
# back to axes units...
xy = self.ax.transAxes.inverted().transform(inches.transform(xy))
if self.orientation == 'horizontal':
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the transpose happens above at line 773

@jklymak jklymak added this to the v3.5.1 milestone Nov 20, 2021
@greglucas greglucas merged commit 3980561 into matplotlib:main Nov 20, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Nov 20, 2021
@jklymak jklymak deleted the fix-colorbar-hline branch November 20, 2021 15:42
timhoffm added a commit that referenced this pull request Nov 20, 2021
…686-on-v3.5.x

Backport PR #21686 on branch v3.5.x (FIX: colorbar for horizontal contours)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: add_lines broken for horizontal colorbars
3 participants
0