Skip to content
Closed
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
3 changes: 3 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ This document explains the changes made to Iris for this release
#. `@rcomer`_ modified :func:`~iris.plot.contourf` to skip the special handling for
antialiasing when data values are too low for it to have an effect. This caused
unexpected artifacts in some edge cases, as shown at :issue:`4086`. (:pull:`4150`)

#. `@rcomer`_ modified :mod:`iris.quickplot` so that, if an axes is supplied, any
colourbar will appear below it, fixing :issue:`4126`. (:pull:`4136`)


💣 Incompatible Changes
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/quickplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _label(cube, mode, result=None, ndims=2, coords=None, axes=None):
if result is not None:
draw_edges = mode == iris.coords.POINT_MODE
bar = plt.colorbar(
result, orientation="horizontal", drawedges=draw_edges
result, orientation="horizontal", drawedges=draw_edges, ax=axes
)
has_known_units = not (
cube.units.is_unknown() or cube.units.is_no_unit()
Expand Down
19 changes: 19 additions & 0 deletions lib/iris/tests/test_quickplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,5 +247,24 @@ def test_not_reference_time_units(self):
self.check_graphic()


@tests.skip_data
@tests.skip_plot
class TestColorbar(tests.IrisTest):
def test_colorbar_location(self):
theta = _load_theta()
theta_slice = next(
theta.slices(["model_level_number", "grid_longitude"])
)

fig1 = plt.figure()
plt.figure()
ax = fig1.add_subplot(1, 1, 1)

result = qplt.contourf(theta_slice, axes=ax)

# Colourbar should appear on same figure as ax, i.e. fig1.
self.assertIs(result.colorbar.ax.get_figure(), fig1)


if __name__ == "__main__":
tests.main()