Skip to content

Commit a11475a

Browse files
authored
Merge pull request #11565 from timhoffm/doc-pyplot-matshow
Update docstring of pyplot.matshow()
2 parents 38fd2ea + 578af6b commit a11475a

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

lib/matplotlib/pyplot.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@ def imsave(fname, arr, **kwargs):
21452145
return matplotlib.image.imsave(fname, arr, **kwargs)
21462146

21472147

2148-
def matshow(A, fignum=None, **kw):
2148+
def matshow(A, fignum=None, **kwargs):
21492149
"""
21502150
Display an array as a matrix in a new figure window.
21512151
@@ -2156,21 +2156,34 @@ def matshow(A, fignum=None, **kw):
21562156
21572157
Tick labels for the xaxis are placed on top.
21582158
2159-
With the exception of *fignum*, keyword arguments are passed to
2160-
:func:`~matplotlib.pyplot.imshow`. You may set the *origin*
2161-
kwarg to "lower" if you want the first row in the array to be
2162-
at the bottom instead of the top.
2159+
Parameters
2160+
----------
2161+
A : array-like(M, N)
2162+
The matrix to be displayed.
2163+
2164+
fignum : None or int or False
2165+
If *None*, create a new figure window with automatic numbering.
2166+
2167+
If *fignum* is an integer, draw into the figure with the given number
2168+
(create it if it does not exist).
2169+
2170+
If 0 or *False*, use the current axes if it exists instead of creating
2171+
a new figure.
2172+
2173+
.. note::
21632174
2175+
Because of how `.Axes.matshow` tries to set the figure aspect
2176+
ratio to be the one of the array, strange things may happen if you
2177+
reuse an existing figure.
21642178
2165-
*fignum*: [ None | integer | False ]
2166-
By default, :func:`matshow` creates a new figure window with
2167-
automatic numbering. If *fignum* is given as an integer, the
2168-
created figure will use this figure number. Because of how
2169-
:func:`matshow` tries to set the figure aspect ratio to be the
2170-
one of the array, if you provide the number of an already
2171-
existing figure, strange things may happen.
2179+
Returns
2180+
-------
2181+
image : `~matplotlib.image.AxesImage`
2182+
2183+
Other Parameters
2184+
----------------
2185+
**kwargs : `~matplotlib.axes.Axes.imshow` arguments
21722186
2173-
If *fignum* is *False* or 0, a new figure window will **NOT** be created.
21742187
"""
21752188
A = np.asanyarray(A)
21762189
if fignum is False or fignum is 0:
@@ -2180,7 +2193,7 @@ def matshow(A, fignum=None, **kw):
21802193
fig = figure(fignum, figsize=figaspect(A))
21812194
ax = fig.add_axes([0.15, 0.09, 0.775, 0.775])
21822195

2183-
im = ax.matshow(A, **kw)
2196+
im = ax.matshow(A, **kwargs)
21842197
sci(im)
21852198

21862199
return im

0 commit comments

Comments
 (0)