MCPcopy
hub / github.com/matplotlib/matplotlib / matshow

Method matshow

lib/matplotlib/axes/_axes.py:8812–8861  ·  view source on GitHub ↗

Plot the values of a 2D matrix or array as color-coded image. The matrix will be shown the way it would be printed, with the first row at the top. Row and column numbering is zero-based. Parameters ---------- Z : (M, N) array-like The m

(self, Z, **kwargs)

Source from the content-addressed store, hash-verified

8810 return ret
8811
8812 def matshow(self, Z, **kwargs):
8813 """
8814 Plot the values of a 2D matrix or array as color-coded image.
8815
8816 The matrix will be shown the way it would be printed, with the first
8817 row at the top. Row and column numbering is zero-based.
8818
8819 Parameters
8820 ----------
8821 Z : (M, N) array-like
8822 The matrix to be displayed.
8823
8824 Returns
8825 -------
8826 `~matplotlib.image.AxesImage`
8827
8828 Other Parameters
8829 ----------------
8830 **kwargs : `~matplotlib.axes.Axes.imshow` arguments
8831
8832 See Also
8833 --------
8834 imshow : More general function to plot data on a 2D regular raster.
8835
8836 Notes
8837 -----
8838 This is just a convenience function wrapping `.imshow` to set useful
8839 defaults for displaying a matrix. In particular:
8840
8841 - Set ``origin='upper'``.
8842 - Set ``interpolation='nearest'``.
8843 - Set ``aspect='equal'``.
8844 - Ticks are placed to the left and above.
8845 - Ticks are formatted to show integer indices.
8846
8847 """
8848 Z = np.asanyarray(Z)
8849 kw = {'origin': 'upper',
8850 'interpolation': 'nearest',
8851 'aspect': 'equal', # (already the imshow default)
8852 **kwargs}
8853 im = self.imshow(Z, **kw)
8854 self.title.set_y(1.05)
8855 self.xaxis.tick_top()
8856 self.xaxis.set_ticks_position('both')
8857 self.xaxis.set_major_locator(
8858 mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True))
8859 self.yaxis.set_major_locator(
8860 mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True))
8861 return im
8862
8863 @_api.make_keyword_only("3.10", "vert")
8864 @_preprocess_data(replace_names=["dataset"])

Callers 5

matshowFunction · 0.80
test_matshowMethod · 0.80
test_matshowFunction · 0.80
test_matshowFunction · 0.80
matshow.pyFile · 0.80

Calls 5

imshowMethod · 0.95
tick_topMethod · 0.80
set_yMethod · 0.45
set_ticks_positionMethod · 0.45
set_major_locatorMethod · 0.45

Tested by 3

test_matshowMethod · 0.64
test_matshowFunction · 0.64
test_matshowFunction · 0.64