What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use Axes.plot() for paired x-y values and Axes.imshow() for a matrix, image, or two-dimensional field. Start by creating a figure and axes with plt.subplots(), then choose the plotting method that matches what the array represents.
Plot paired NumPy values with plot()
When each x value corresponds to a y value, pass both arrays to ax.plot(x, y). This example samples a sine curve, labels its axes, and displays the figure:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2 * np.pi, 100)
y = np.sin(x)
fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_xlabel("x")
ax.set_ylabel("sin(x)")
ax.set_title("Sine curve")
plt.show()
Here, x and y are paired coordinates, and the axis labels explain their meaning. Matplotlib’s Quick start guide describes a Figure as the container and an Axes as the region where data is plotted. It recommends the plt.subplots() pattern for creating them; using methods on ax keeps the plot explicit and makes it easier to add panels later.
For a sequence of y values whose x positions mean sample number, ax.plot(y) is a convenience form: the horizontal positions represent the samples rather than a separate measured x array. Use ax.plot(x, y) when you have meaningful x coordinates.
#1 Best Overall
Show a matrix or image with imshow()
Use imshow when a two-dimensional array represents a raster image or a field arranged on a grid, rather than a single x-y series. A scalar matrix has shape (M, N), where rows and columns define its grid. For scalar values, Matplotlib normalizes the numbers and maps them to colors through a colormap; the colors are a visual encoding, not colors stored in the matrix.
fig, ax = plt.subplots()
image = ax.imshow(matrix, cmap="viridis")
fig.colorbar(image, ax=ax, label="value")
ax.set_title("Matrix values")
plt.show()
The colorbar helps readers relate displayed colors to values. For grayscale intensity data, choose a grayscale colormap and set vmin and vmax when those limits match the data scale. The imshow API documentation describes scalar, RGB, and RGBA input: RGB image arrays have shape (M, N, 3), while RGBA arrays have shape (M, N, 4). In those color arrays, the final dimension supplies the color channels directly.
Rank #2
Set image orientation and coordinate meaning
By default, imshow places pixel centers at integer coordinates, with the origin at the center of pixel (0, 0). That means the axes ordinarily indicate array indices, not necessarily physical or scientific coordinates.
- Use
originto choose whether the first row appears at the top or bottom. - Use
extentwhen the axes should show meaningful data bounds instead of pixel-index coordinates. - Choose
interpolationdeliberately. Resampling can change appearance through smoothing or aliasing when the displayed image size differs from the array dimensions.
These settings are documented in the imshow API and Matplotlib’s image interpolation guide. If a matrix represents measurements over real-world coordinates, configure the displayed bounds so readers do not mistake row and column indices for those measurements.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Compare multiple arrays in panels
For separate series or matrices that should be viewed together, create a grid of axes with plt.subplots(rows, columns) and draw each dataset on its corresponding axes. Shared scales can make comparisons easier when the data are comparable.
fig, axs = plt.subplots(2, 2, sharex="all", sharey="all")
axs[0, 0].plot(x, y1)
axs[0, 1].plot(x, y2)
axs[1, 0].plot(x, y3)
axs[1, 1].plot(x, y4)
plt.show()
With a multi-row, multi-column layout, axs is indexed by row and column, as in axs[0, 1]. For other layouts, the returned value can be a single Axes, a one-dimensional collection, or a two-dimensional grid depending on the requested layout and the squeeze setting. Matplotlib’s subplots documentation covers shared axes options: True or 'all', 'row', 'col', or independent axes.
Decide whether to call plt.show()
In a script or an environment that does not automatically render figures, plt.show() displays the plot. Some interactive environments display figures without an explicit call, so whether to include it depends on how the code is being run. Matplotlib’s Quick start guide demonstrates plt.show() and notes that it can be omitted in some environments.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




