Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 29ec51b

Browse files
committed
matshow: behave well with origin kwarg
1 parent a892e3b commit 29ec51b

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5770,7 +5770,7 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
57705770
marker_obj.get_transform())
57715771
if not marker_obj.is_filled():
57725772
edgecolors = 'face'
5773-
5773+
57745774
collection = mcoll.PathCollection(
57755775
(path,), scales,
57765776
facecolors = colors,
@@ -8214,19 +8214,16 @@ def matshow(self, Z, **kwargs):
82148214
*Z* anything that can be interpreted as a 2-D array
82158215
82168216
kwargs all are passed to :meth:`~matplotlib.axes.Axes.imshow`.
8217-
:meth:`matshow` sets defaults for *extent*, *origin*,
8218-
*interpolation*, and *aspect*; use care in overriding the
8219-
*extent* and *origin* kwargs, because they interact. (Also,
8220-
if you want to change them, you probably should be using
8221-
imshow directly in your own version of matshow.)
8217+
:meth:`matshow` sets defaults for *origin*,
8218+
*interpolation*, and *aspect*; if you want row zero to
8219+
be at the bottom instead of the top, you can set the *origin*
8220+
kwarg to "lower".
82228221
82238222
Returns: an :class:`matplotlib.image.AxesImage` instance.
82248223
'''
8225-
Z = np.asarray(Z)
8224+
Z = np.asanyarray(Z)
82268225
nr, nc = Z.shape
8227-
extent = [-0.5, nc-0.5, nr-0.5, -0.5]
8228-
kw = {'extent': extent,
8229-
'origin': 'upper',
8226+
kw = {'origin': 'upper',
82308227
'interpolation': 'nearest',
82318228
'aspect': 'equal'} # (already the imshow default)
82328229
kw.update(kwargs)

lib/matplotlib/pyplot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,8 +1710,10 @@ def matshow(A, fignum=None, **kw):
17101710
17111711
Tick labels for the xaxis are placed on top.
17121712
1713-
With the exception of fignum, keyword arguments are passed to
1714-
:func:`~matplotlib.pyplot.imshow`.
1713+
With the exception of *fignum*, keyword arguments are passed to
1714+
:func:`~matplotlib.pyplot.imshow`. You may set the *origin*
1715+
kwarg to "lower" if you want the first row in the array to be
1716+
at the bottom instead of the top.
17151717
17161718
17171719
*fignum*: [ None | integer | False ]
@@ -1724,6 +1726,7 @@ def matshow(A, fignum=None, **kw):
17241726
17251727
If *fignum* is *False* or 0, a new figure window will **NOT** be created.
17261728
"""
1729+
A = np.asanyarray(A)
17271730
if fignum is False or fignum is 0:
17281731
ax = gca()
17291732
else:

0 commit comments

Comments
 (0)