From 42fe71e6fd37d6329b17715bb9e24a86c46f2ae2 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 14 Oct 2020 14:48:23 +0200 Subject: [PATCH] Use ax.add_image rather than ax.images.append in NonUniformImage example add_image sets up a few additional things on the artist (it makes `remove()` work and generates a label), and avoids directly manipulating the `.images` attribute, which may become read-only in the future. --- examples/images_contours_and_fields/image_nonuniform.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/images_contours_and_fields/image_nonuniform.py b/examples/images_contours_and_fields/image_nonuniform.py index b429826c8285..9c1012310b63 100644 --- a/examples/images_contours_and_fields/image_nonuniform.py +++ b/examples/images_contours_and_fields/image_nonuniform.py @@ -31,7 +31,7 @@ im = NonUniformImage(ax, interpolation=interp, extent=(-4, 4, -4, 4), cmap=cm.Purples) im.set_data(x, y, z) -ax.images.append(im) +ax.add_image(im) ax.set_xlim(-4, 4) ax.set_ylim(-4, 4) ax.set_title(interp) @@ -40,7 +40,7 @@ im = NonUniformImage(ax, interpolation=interp, extent=(-64, 64, -4, 4), cmap=cm.Purples) im.set_data(x2, y, z) -ax.images.append(im) +ax.add_image(im) ax.set_xlim(-64, 64) ax.set_ylim(-4, 4) ax.set_title(interp) @@ -51,7 +51,7 @@ im = NonUniformImage(ax, interpolation=interp, extent=(-4, 4, -4, 4), cmap=cm.Purples) im.set_data(x, y, z) -ax.images.append(im) +ax.add_image(im) ax.set_xlim(-4, 4) ax.set_ylim(-4, 4) ax.set_title(interp) @@ -60,7 +60,7 @@ im = NonUniformImage(ax, interpolation=interp, extent=(-64, 64, -4, 4), cmap=cm.Purples) im.set_data(x2, y, z) -ax.images.append(im) +ax.add_image(im) ax.set_xlim(-64, 64) ax.set_ylim(-4, 4) ax.set_title(interp)