Skip to content

Colorbar redo again! #20501

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
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions doc/api/next_api_changes/behavior/20054-JMK.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
Axes used to make colorbar now wrapped
======================================

The axes used to place a colorbar is now wrapped by a new parent class
(``ColorbarAxes``) when the colorbar is created::

cb = fig.colorbar(im, cax=cax)

This means that ``cb.ax`` is no longer the same object as ``cax``. However,
we map all the methods from ``cb.ax`` onto ``cax`` so ``cax`` should remain
functionally the same as ``cb.ax``.

Colorbar lines no longer clipped
================================

Expand Down
6 changes: 5 additions & 1 deletion lib/matplotlib/_constrained_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,11 @@ def _reposition_colorbar(cbax, renderer, *, offset=None):
pbcb = trans_fig_to_subfig.transform_bbox(pbcb)
cbax.set_transform(fig.transSubfigure)
cbax._set_position(pbcb)
cbax.set_aspect(aspect, anchor=anchor, adjustable='box')
cbax.set_anchor(anchor)
if location in ['bottom', 'top']:
aspect = 1 / aspect
cbax.set_box_aspect(aspect)
cbax.set_aspect('auto')
return offset


Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2380,6 +2380,8 @@ def _update_patch_limits(self, patch):
return
patch_trf = patch.get_transform()
updatex, updatey = patch_trf.contains_branch_seperately(self.transData)
if not (updatex or updatey):
return
Copy link
Member Author

Choose a reason for hiding this comment

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

Calling the transform below blows up needlessly because it is called, and then does nothing....

if self.name != "rectilinear":
# As in _update_line_limits, but for axvspan.
if updatex and patch_trf == self.get_yaxis_transform():
Expand Down
Loading