Redo colorbar overhaul. · matplotlib/matplotlib@277b5eb · GitHub
Skip to content

Commit 277b5eb

Browse files
committed
Redo colorbar overhaul.
Previous overhaul packaged an inner and outer axes in a container "ColorbarAxes" and tried to dispatch methods between them. This overhaul takes the _much_ simpler approach of resizing the image using a custom _axes_locator that a) calls any existing locator b) or just uses the axes default position. The custom _axes_locator then shrinks the axes in the appropriate direction to make room for extend tri/rectangles. As with the previous fix, the extend tri/rectangles are drawn as patches in axes co-ordinates, rather than pcolormesh in "data" co-ordinates.
1 parent 8c764dc commit 277b5eb

14 files changed

Lines changed: 564 additions & 565 deletions

File tree

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

Lines changed: 0 additions & 12 deletions

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

0 commit comments

Comments
 (0)