Skip to content
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
6 changes: 6 additions & 0 deletions doc/users/next_whats_new/mpl_toolkit_colorbar_pad.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Fix padding of single colorbar for ``ImageGrid``
------------------------------------------------

``ImageGrid`` with ``cbar_mode="single"`` no longer adds the ``axes_pad`` between the
axes and the colorbar for ``cbar_location`` "left" and "bottom". If desired, add additional spacing
using ``cbar_pad``.
9 changes: 7 additions & 2 deletions lib/mpl_toolkits/axes_grid1/axes_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ def __init__(self, fig,
cbar_location : {"left", "right", "bottom", "top"}, default: "right"
cbar_pad : float, default: None
Padding between the image axes and the colorbar axes.

.. versionchanged:: 3.10
``cbar_mode="single"`` no longer adds *axes_pad* between the axes
and the colorbar if the *cbar_location* is "left" or "bottom".

cbar_size : size specification (see `.Size.from_any`), default: "5%"
Colorbar size.
cbar_set_cax : bool, default: True
Expand Down Expand Up @@ -439,7 +444,7 @@ def _init_locators(self):
self.cbar_axes[0].set_visible(True)

for col, ax in enumerate(self.axes_row[0]):
if h:
if col != 0:
h.append(self._horiz_pad_size)

if ax:
Expand Down Expand Up @@ -468,7 +473,7 @@ def _init_locators(self):
v_ax_pos = []
v_cb_pos = []
for row, ax in enumerate(self.axes_column[0][::-1]):
if v:
if row != 0:
v.append(self._vert_pad_size)

if ax:
Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def test_image_grid_single_bottom():

fig = plt.figure(1, (2.5, 1.5))
grid = ImageGrid(fig, (0, 0, 1, 1), nrows_ncols=(1, 3),
axes_pad=(0.2, 0.15), cbar_mode="single",
axes_pad=(0.2, 0.15), cbar_mode="single", cbar_pad=0.3,
cbar_location="bottom", cbar_size="10%", label_mode="1")
# 4-tuple rect => Divider, isinstance will give True for SubplotDivider
assert type(grid.get_divider()) is Divider
Expand Down