From 50fd61abf06bb121ead691a750cfe554679d3203 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 1 Nov 2023 17:03:59 -0400 Subject: [PATCH] Backport PR #27244: Clarify semantics of plt.matshow(..., fignum=...). --- lib/matplotlib/pyplot.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 3f41376e0a63..42ea405c17cc 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -2413,18 +2413,15 @@ def matshow(A: ArrayLike, fignum: None | int = None, **kwargs) -> AxesImage: The matrix to be displayed. fignum : None or int - If *None*, create a new figure window with automatic numbering. + If *None*, create a new, appropriately sized figure window. - If a nonzero integer, draw into the figure with the given number - (create it if it does not exist). + If 0, use the current Axes (creating one if there is none, without ever + adjusting the figure size). - If 0, use the current axes (or create one if it does not exist). - - .. note:: - - Because of how `.Axes.matshow` tries to set the figure aspect - ratio to be the one of the array, strange things may happen if you - reuse an existing figure. + Otherwise, create a new Axes on the figure with the given number + (creating it at the appropriate size if it does not exist, but not + adjusting the figure size otherwise). Note that this will be drawn on + top of any preexisting Axes on the figure. Returns -------