Skip to content

Reuse colorbar outline and patch when updating the colorbar. #15981

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 1 commit into from
Mar 14, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Dec 19, 2019

... so that changes to the outline edgecolor are kept.

Closes #15980.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@timhoffm
Copy link
Member

flake8:

./lib/matplotlib/colorbar.py:1275:9: F821 undefined name 'ax'
./lib/matplotlib/colorbar.py:1280:9: F821 undefined name 'ax'

... so that changes to the outline edgecolor are kept.
@anntzer
Copy link
Contributor Author

anntzer commented Dec 20, 2019

oops, fixed

Comment on lines +1271 to +1280
self.outline = mpatches.Polygon(
np.empty((0, 2)),
edgecolor=mpl.rcParams['axes.edgecolor'], facecolor='none',
linewidth=mpl.rcParams['axes.linewidth'], closed=True, zorder=2)
self.ax.add_artist(self.outline)
self.outline.set(clip_box=None, clip_path=None)
self.patch = mpatches.Polygon(
np.empty((0, 2)),
color=mpl.rcParams['axes.facecolor'], linewidth=0.01, zorder=-1)
self.ax.add_artist(self.patch)
Copy link
Member

Choose a reason for hiding this comment

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

This code is repeated from __init__. Should this be moved to a private helper to remove duplication? Maybe only returning the outline and patch without adding them to ax within the helper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is getting deprecated in #15982.

@anntzer anntzer added this to the v3.3.0 milestone Jan 13, 2020
@QuLogic QuLogic merged commit b42d6d9 into matplotlib:master Mar 14, 2020
@anntzer anntzer deleted the keepcbaroutline branch March 14, 2020 11:42
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.

Is the reset of the colorbar's edgecolor when updating the corresponding image clim wanted behaviour?
3 participants