The imshow() function with parameters interpolation='nearest' and cmap='hot' should do what you want.

Please review the interpolation parameter details, and see Interpolations for imshow and Image antialiasing.

import matplotlib.pyplot as plt
import numpy as np

a = np.random.random((16, 16))
plt.imshow(a, cmap='hot', interpolation='nearest')
plt.show()

Answer from P. Camilleri on Stack Overflow
🌐
Matplotlib
matplotlib.org › stable › gallery › images_contours_and_fields › image_annotated_heatmap.html
Annotated heatmap — Matplotlib 3.11.2 documentation
def heatmap(data, row_labels, col_labels, ax=None, cbar_kw=None, cbarlabel="", **kwargs): """ Create a heatmap from a numpy array and two lists of labels. Parameters ---------- data A 2D numpy array of shape (M, N). row_labels A list or array of length M with the labels for the rows. col_labels A list or array of length N with the labels for the columns. ax A `matplotlib.axes.Axes` instance to which the heatmap is plotted.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-draw-2d-heatmap-using-matplotlib-in-python
How to draw 2D Heatmap using Matplotlib in python? - GeeksforGeeks
A 2-D Heatmap is a data visualization tool that helps to represent the magnitude of the matrix in form of a colored table. In Python, we can plot 2-D Heatmaps using the Matplotlib and Seaborn packages.
Published: July 23, 2025
🌐
Seaborn
seaborn.pydata.org › generated › seaborn.heatmap.html
seaborn.heatmap — seaborn 0.13.2 documentation - PyData |
All other keyword arguments are passed to matplotlib.axes.Axes.pcolormesh(). Returns: axmatplotlib Axes · Axes object with the heatmap. See also · clustermap · Plot a matrix using hierarchical clustering to arrange the rows and columns.
🌐
PYTHON CHARTS
python-charts.com › home › correlation › heat map in matplotlib
Heat map in matplotlib | PYTHON CHARTS
October 13, 2022 - The previous examples show how to create a heat map using matplotlib, but a lot of code is required to customize the plot. For that reason you can use the following functions from the matplotlib documentation: def heatmap(data, row_labels, col_labels, ax = None, cbar_kw = {}, cbarlabel = "", **kwargs): """ Create a heatmap from a numpy array and two lists of labels.
🌐
TutorialsPoint
tutorialspoint.com › matplotlib › matplotlib_heatmap.htm
Matplotlib - Heat Map
In the following example, we are creating a simple heatmap using random 2D data. The colormap 'viridis' is applied to represent the intensity of values, and a colorbar is added for reference − · import matplotlib.pyplot as plt import numpy as np # Generating random 2D data data = np.random.random((10, 10)) # Creating a basic heatmap plt.imshow(data, cmap='viridis', aspect='auto', origin='upper') plt.colorbar(label='Intensity') plt.title('Basic Heatmap') plt.show()
🌐
Scaler
scaler.com › home › topics › matplotlib › matplotlib heatmap
Matplotlib Heatmap - Scaler Topics
December 20, 2022 - Python's Matplotlib offers a 2-D data visualization tool called Matplotlip heatmap, which can represent the magnitude of a phenomenon. Matplotlib heatmaps represents this magnitude in the form of colors.Different data values are represented by different colours.
🌐
Python-Fiddle
python-fiddle.com › tutorials › matplotlib-heatmap
Creating and Customizing Heatmaps in Matplotlib
### Heatmap with Annotations Adding annotations can make your heatmap more informative by displaying the exact values within each cell. import matplotlib.pyplot as plt import numpy as np # Sample data data = np.random.rand(10, 10) fig, ax = plt.subplots() cax = ax.imshow(data, cmap='viridis') # Add color bar fig.colorbar(cax) # Annotate the heatmap for i in range(data.shape[0]): for j in range(data.shape[1]): ax.text(j, i, f'{data[i, j]:.2f}', ha='center', va='center', color='w') plt.title('Heatmap with Annotations') plt.show()
Find elsewhere
🌐
Python Graph Gallery
python-graph-gallery.com › the python graph gallery › heatmap › heatmap for timeseries with python and matplotlib
Heatmap for timeseries with Python and Matplotlib
2 weeks ago - This post shows how to create a heatmap with Python and Matplotlib for timeseries. It represents the evolution of a temperature along days and hours, using multiple subplots.
🌐
Rip Tutorial
riptutorial.com › heatmap
matplotlib Tutorial => Heatmap
The following source code illustrates heatmaps using bivariate normally distributed numbers centered at 0 in both directions (means [0.0, 0.0]) and a with a given covariance matrix. The data is generated using the numpy function numpy.random.multivariate_normal; it is then fed to the hist2d function of pyplot matplotlib.pyplot.hist2d.
🌐
GitHub
rasbt.github.io › mlxtend › user_guide › plotting › heatmap
heatmap: Create a heatmap in matplotlib - mlxtend
from mlxtend.plotting import heatmap import matplotlib.pyplot as plt import numpy as np import pandas as pd np.random.seed(123) some_array = np.random.random((20, 30)) heatmap(some_array, figsize=(20, 10)) plt.show()
🌐
Python Pool
pythonpool.com › home › matplotlib › matplotlib heatmap with imshow(): colorbars, labels, and annotations
Matplotlib Heatmap with imshow(): Colorbars, Labels, and Annotations
July 13, 2026 - Create Matplotlib heatmaps with imshow(), colorbars, tick labels, annotations, colormaps, and readable correlation matrices.
🌐
DevGenius
blog.devgenius.io › understanding-heatmaps-in-matplotlib-with-custom-colormaps-d2613c2ddd75
Understanding Heatmaps in Matplotlib with Custom Colormaps | by Someone | Dev Genius
October 9, 2024 - Heatmaps are a powerful way to represent 2D data visually, especially when working with larger datasets. By using matplotlib’s imshow() function, you can create effective heatmaps with customizable colormaps and visual parameters.
🌐
Plotivy
plotivy.app › home › blog › how to create a heatmap in python: matplotlib, seaborn, and plotly
How to Create a Heatmap in Python: matplotlib, seaborn, and plotly | Plotivy
March 21, 2026 - Generate an annotated heatmap with a readable colormap and export-ready styling in one click.Generate my heatmap → ... One concise tip each week for cleaner, faster scientific figures. Built for researchers who publish. import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import numpy as np rng = np.random.default_rng(42) df = pd.DataFrame(rng.standard_normal((100, 5)), columns=["A", "B", "C", "D", "E"]) corr = df.corr() mask = np.triu(np.ones_like(corr, dtype=bool)) # upper triangle mask fig, ax = plt.subplots(figsize=(6, 5)) sns.heatmap(corr, mask=mask, annot=True, fmt=".2f", cmap="coolwarm", vmin=-1, vmax=1, square=True, linewidths=0.5, ax=ax) ax.set_title("Correlation Matrix") plt.tight_layout()
🌐
YouTube
youtube.com › watch
Create Heatmap with Python Matplotlib | Python Matplotlib | Python Tutorial - YouTube
A heatmap is a graphical representation of data where individual values within a matrix are represented using a color scale. It's an effective tool for visua...
Published: October 30, 2023
🌐
Medium
medium.com › @SeanAT19 › how-to-create-heatmaps-using-matplotlib-pyplot-db9ff94d25e8
How to create Heatmaps using matplotlib.pyplot | by Sean Atukorala | Medium
April 30, 2023 - How to create Heatmaps using matplotlib.pyplot In this tutorial we will go over how to create heat maps such as this one using Pandas and matplotlib.pyplot: What is …
🌐
Datavizpyr
datavizpyr.com › home › how to make heatmap with matplotlib in python
How to Make a Heatmap in Python with Matplotlib (Step-by-Step Guide)
August 29, 2025 - By default, Matplotlib’s imshow() use viridis color palette to make the heatmap. You can change the colormap using the cmap argument.
🌐
CodersLegacy
coderslegacy.com › home › python › plotting a 2d heatmap with matplotlib in python
Plotting a 2D Heatmap With Matplotlib in Python - CodersLegacy
July 15, 2022 - Our goal is to ensure that the heatmap is uniform (which it might not be if we use the literal values). You can try it both ways, and see the difference for yourself. (You may end up needing the other technique depending on your data, so you should understand both) Here is the final code. import matplotlib.pyplot as plt import numpy as np x, y = np.meshgrid(np.linspace(-3, 3, 100), np.linspace(-3, 3, 100)) z = (1 - x*y) - np.sin(x**2 + y**2 ) z = z[:-1, :-1] fig, ax = plt.subplots() ax.set_title('Heatmap with Colormesh') plt.pcolormesh(x, y, z, cmap='RdBu', vmin = -np.abs(z).max(), vmax = np.abs(z).max()) plt.colorbar() plt.show()