Matplotlib.pyplot.matshow() in Python Last Updated : 03 Sep, 2021 Comments Improve Suggest changes Like Article Like Report Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. It was introduced by John Hunter in the year 2002. matplotlib.pyplot.matshow() matplotlib.pyplot.matshow() function is used to represent an array as a matrix in a new figure window. the upper left-hand corner is set as the origin and the rows (first dimension of the array) are displayed in a horizontal form. The aspect ratio of the figure window is set according to the array to avoid short and narrow figures. The x-axis Tick labels are placed at the top. Syntax: matplotlib.pyplot.matshow(A, fignum=None, **kwargs)Parameters: A:: It is an array like object that represents the matrix. It is a required parameter.fignum: It accepts three values namely 'None', 'False' or an integer value. If the value is set to None it would create a new window of the figure with automated numbering. If the value is a non-zero integer then it is drawn into the figure respective to the given number or it creates it if it doesn't exist. If the '0' is set as the value of this parameter then it uses the current axes or it creates one if it doesn't exist. Returns: It returns an image of Axesimage class.Other parameters: It also accepts the imshow argument for showing image. Example 1: Python3 import matplotlib.pyplot as plot import numpy as np # an array with linearly increasing values array = np.diag(range(20)) plot.matshow(array) plot.show() Output: Example 2: Python3 import numpy as np import matplotlib.pyplot as plt alphabets = ['A', 'B', 'C', 'D', 'E'] # randomly generated array random_array = np.random.random((5, 5)) figure = plt.figure() axes = figure.add_subplot(111) # using the matshow() function caxes = axes.matshow(random_array, interpolation ='nearest') figure.colorbar(caxes) axes.set_xticklabels(['']+alphabets) axes.set_yticklabels(['']+alphabets) plt.show() Output: Comment More infoAdvertise with us Next Article Matplotlib.pyplot.matshow() in Python R RajuKumar19 Follow Improve Article Tags : Python Write From Home Python-Library Python-matplotlib Practice Tags : python Similar Reads Matplotlib.pyplot.psd() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. matplotlib.pyplot.csd() Function The csd() function in pyplot module of matplotlib library is used to plo 3 min read matplotlib.pyplot.pcolormesh() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. matplotlib.pyplot.pcolormesh() Function: The pcolormesh() function in pyplot module of matplotlib library 2 min read Matplotlib.pyplot.sci() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, 2 min read Matplotlib.pyplot.ion() in Python Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. The matplotlib.pyplot.ion() is used to turn on interactive mode. To check the status of 4 min read Matplotlib.pyplot.gca() in Python Matplotlib is a library in Python and it is a numerical - mathematical extension for the NumPy library. Pyplot is a state-based interface to a Matplotlib module that provides a MATLAB-like interface.  matplotlib.pyplot.gca() Function The gca() function in pyplot module of matplotlib library is used 2 min read Matplotlib.pyplot.sca() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, 1 min read Matplotlib.pyplot.gcf() in Python Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. matplotlib.pyplot.gcf() matplotlib.pyplot.gcf() is primarily used to get the current fi 2 min read Matplotlib.pyplot.gci() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, 2 min read Matplotlib.pyplot.csd() in Python csd() method in Matplotlib is used to compute and plot the Cross Spectral Density (CSD) of two signals. It helps analyze the frequency domain relationship between two time series, revealing how the power of one signal is distributed relative to the other signal across frequencies. It's key features 4 min read Matplotlib.pyplot.cla() in Python Matplotlib is a library in Python and it is numerical - mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, 1 min read Like