From 159100577fc64953f1724d7e3252d742b6bbf5a4 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sat, 21 Dec 2024 17:39:07 +0100 Subject: [PATCH 1/2] DOC: Improve NonUniformImage docs --- .../images_contours_and_fields/image_nonuniform.py | 9 ++++++--- lib/matplotlib/image.py | 10 +++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/galleries/examples/images_contours_and_fields/image_nonuniform.py b/galleries/examples/images_contours_and_fields/image_nonuniform.py index 629f37bf61d5..991e7bade521 100644 --- a/galleries/examples/images_contours_and_fields/image_nonuniform.py +++ b/galleries/examples/images_contours_and_fields/image_nonuniform.py @@ -3,9 +3,12 @@ Image nonuniform ================ -This illustrates the NonUniformImage class. It is not -available via an Axes method, but it is easily added to an -Axes instance as shown here. +`.NonUniformImage` is a generalized image with pixels on a rectilinear grid, +i.e. it allows rows and columns with individual heights / widths. + +There is no high-level plotting method on `~.axes.Axes` or `.pyplot` to +create a NonUniformImage. Instead, you have to instantiate the image +explicitly add it to the Axes using `.Axes.add_image`. """ import matplotlib.pyplot as plt diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 3d94d90708f3..3231c2a1d913 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -808,7 +808,7 @@ def get_filterrad(self): class AxesImage(_ImageBase): """ - An image attached to an Axes. + An image, i.e. data on a regular grid, attached to an Axes. Parameters ---------- @@ -995,6 +995,14 @@ def get_cursor_data(self, event): class NonUniformImage(AxesImage): + """ + An image with pixels on a rectilinear grid. + + In contrast to `.AxesImage`, where pixels are on a regular grid, + NonUniformImage allows rows and columns with individual heights / widths. + + See also :doc:`/gallery/images_contours_and_fields/image_nonuniform`. + """ def __init__(self, ax, *, interpolation='nearest', **kwargs): """ From 2176655cea243b93905f20c1b6df648afd01409e Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Tue, 29 Apr 2025 10:49:45 +0200 Subject: [PATCH 2/2] Update lib/matplotlib/image.py Co-authored-by: David Stansby --- lib/matplotlib/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 3231c2a1d913..3566f19eca8d 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -808,7 +808,7 @@ def get_filterrad(self): class AxesImage(_ImageBase): """ - An image, i.e. data on a regular grid, attached to an Axes. + An image with pixels on a regular grid, attached to an Axes. Parameters ----------