8000 Merge pull request #20501 from jklymak/colorbar-try3-justmod-transform · matplotlib/matplotlib@4d1cd5e · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d1cd5e

Browse files
authored
Merge pull request #20501 from jklymak/colorbar-try3-justmod-transform
Colorbar redo again!
2 parents 8c764dc + 277b5eb commit 4d1cd5e

File tree

14 files changed

+564
-565
lines changed

14 files changed

+564
-565
lines changed

doc/api/next_api_changes/behavior/20054-JMK.rst

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
Axes used to make colorbar now wrapped
2-
======================================
3-
4-
The axes used to place a colorbar is now wrapped by a new parent class
5-
(``ColorbarAxes``) when the colorbar is created::
6-
7-
cb = fig.colorbar(im, cax=cax)
8-
9-
This means that ``cb.ax`` is no longer the same object as ``cax``. However,
10-
we map all the methods from ``cb.ax`` onto ``cax`` so ``cax`` should remain
11-
functionally the same as ``cb.ax``.
12-
131
Colorbar lines no longer clipped
142
================================
153

lib/matplotlib/_constrained_layout.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,11 @@ def _reposition_colorbar(cbax, renderer, *, offset=None):
575575
pbcb = trans_fig_to_subfig.transform_bbox(pbcb)
576576
cbax.set_transform(fig.transSubfigure)
577577
cbax._set_position(pbcb)
578-
cbax.set_aspect(aspect, anchor=anchor, adjustable='box')
578+
cbax.set_anchor(anchor)
579+
if location in ['bottom', 'top']:
580+
aspect = 1 / aspect
581+
cbax.set_box_aspect(aspect)
582+
cbax.set_aspect('auto')
579583
return offset
580584

581585

lib/matplotlib/axes/_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,6 +2380,8 @@ def _update_patch_limits(self, patch):
23802380
return
23812381
patch_trf = patch.get_transform()
23822382
updatex, updatey = patch_trf.contains_branch_seperately(self.transData)
2383+
if not (updatex or updatey):
2384+
return
23832385
if self.name != "rectilinear":
23842386
# As in _update_line_limits, but for axvspan.
23852387
if updatex and patch_trf == self.get_yaxis_transform():

0 commit comments

Comments
 (0)
0