Skip to content

Commit d2569a3

Browse files
committed
Clarify semantics of plt.matshow(..., fignum=...).
The semantics of the fignum parameter are rather confusing (in particular wrt. whether the figure gets resized or not -- it only does if fignum=(None or a non-existing figure number) (which creates a new figure), but not if fignum=0 (which also creates a new figure). It's probably not worth fixing that (if anything we should just point users to Axes.matshow, which is just fine), but we can still improve the documentation.
1 parent e5c6c7c commit d2569a3

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/matplotlib/pyplot.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -2412,18 +2412,15 @@ def matshow(A: ArrayLike, fignum: None | int = None, **kwargs) -> AxesImage:
24122412
The matrix to be displayed.
24132413
24142414
fignum : None or int
2415-
If *None*, create a new figure window with automatic numbering.
2415+
If *None*, create a new, appropriately sized figure window.
24162416
2417-
If a nonzero integer, draw into the figure with the given number
2418-
(create it if it does not exist).
2417+
If 0, use the current Axes (creating one if there is none, without ever
2418+
adjusting the figure size).
24192419
2420-
If 0, use the current axes (or create one if it does not exist).
2421-
2422-
.. note::
2423-
2424-
Because of how `.Axes.matshow` tries to set the figure aspect
2425-
ratio to be the one of the array, strange things may happen if you
2426-
reuse an existing figure.
2420+
Otherwise, create a new Axes on the figure with the given number
2421+
(creating it at the appropriate size if it does not exist, but not
2422+
adjusting the figure size otherwise). Note that this will be drawn on
2423+
top of any preexisting Axes on the figure.
24272424
24282425
Returns
24292426
-------

0 commit comments

Comments
 (0)