From 7dab28b1b19c63f568955d06f60f484fc1bffa66 Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Tue, 29 Apr 2025 16:40:06 +0200 Subject: [PATCH] Backport PR #29370: 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 8191c5db0b2e..bf92ec985ae2 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -818,7 +818,7 @@ def get_filterrad(self): class AxesImage(_ImageBase): """ - An image attached to an Axes. + An image with pixels on a regular grid, attached to an Axes. Parameters ---------- @@ -1005,6 +1005,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): """