To get gradiated colours you can do:
import matplotlib.pyplot as plt
# Builtin colourmap "seismic" has the blue-white-red
# scale you want
plt.pcolor(np.array(data), cmap=plt.cm.seismic, vmin=0, vmax=2)
plt.colorbar()
plt.show()
Here I've set vmin and vmax so that they're equally spaced
around the white value at 1.0, unfortunately I think this means
that any values above 2.0 don't become any darker than those
at 2.0. You may get better results by choosing a wider
range, even if this means the scale includes negative
values, e.g. vmin=-2, vmax=4.

Scaler
scaler.com › home › topics › matplotlib › matplotlib heatmap
Matplotlib Heatmap - Scaler Topics
December 20, 2022 - The imshow() function in pyplot ... The Colormap instance of the plot. norm : str or Normalize The normalization method used to scale scalar data to the [0, 1] range before using cmap to map to colours....
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.
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.
How do I make a heatmap in Matplotlib?
Pass a two-dimensional array to ax.imshow() and add a colorbar that explains the mapping from values to colors.
pythonpool.com
pythonpool.com › home › matplotlib › matplotlib heatmap with imshow(): colorbars, labels, and annotations
Matplotlib Heatmap with imshow(): Colorbars, Labels, and Annotations
How do I add labels to a Matplotlib heatmap?
Set tick positions and labels with set_xticks(), set_xticklabels(), set_yticks(), and set_yticklabels().
pythonpool.com
pythonpool.com › home › matplotlib › matplotlib heatmap with imshow(): colorbars, labels, and annotations
Matplotlib Heatmap with imshow(): Colorbars, Labels, and Annotations
How do I change the color palette of a heatmap in Matplotlib?
Pass cmap to imshow(), e.g., cmap='coolwarm' or 'magma'. For custom colormaps, use matplotlib.colors (e.g., LinearSegmentedColormap or ListedColormap).
datavizpyr.com
datavizpyr.com › home › how to make heatmap with matplotlib in python
How to Make a Heatmap in Python with Matplotlib (Step-by-Step Guide)
Python-Fiddle
python-fiddle.com › tutorials › matplotlib-heatmap
Creating and Customizing Heatmaps in Matplotlib
import matplotlib.pyplot as plt import numpy as np # Sample data data = np.random.rand(10, 10) plt.imshow(data, cmap='viridis') plt.colorbar() plt.title('Basic Heatmap with imshow') plt.show() - **`imshow(data, cmap='viridis')`** displays the data as an image, where `data` is a 2D array. - **`colorbar()`** adds a color bar to indicate the scale of values.
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
Matplotlib
discourse.matplotlib.org › community › matplotlib-users
plotting heatmap matrices in matplotlib with scale - matplotlib-users - Matplotlib
June 6, 2010 - Hi all, How can I plot a matrix of values as a heatmap where values are shown from green to red intensities, or blue to yellow intensities, like in the following figure? http://www.coriell.org/images/microarray.gif I want to have the option of doing this with either green-red maps or blue-yellow ...
TutorialsPoint
tutorialspoint.com › matplotlib › matplotlib_heatmap.htm
Matplotlib - Heat Map
Clusters in a heatmap may appear as denser regions with similar color patterns, indicating that the corresponding rows or columns share similarities in their values. Now, we are generating random 2D data and then creating clusters in a specific region. visually represents the data intensity using the 'YlGnBu' color map. The resulting plot shows the clustered patterns in the data, with a color bar indicating the intensity scale − · import matplotlib.pyplot as plt import numpy as np # Generating random clustered 2D data data = np.random.random((8, 12)) # Creating clusters in a portion of the data data[:, 3:8] += 1 # Creating a clustered heatmap plt.imshow(data, cmap='YlGnBu', aspect='auto', origin='upper') plt.colorbar(label='Intensity') plt.title('Clustered Heatmap') plt.show()
Stack Abuse
stackabuse.com › ultimate-guide-to-heatmaps-in-seaborn-with-python
Ultimate Guide to Heatmaps in Seaborn with Python
September 27, 2023 - Now that we have prepared the data it is easy to plot a heatmap using Seaborn. First make sure you've imported the Seaborn library: import seaborn as sns import matplotlib.pyplot as plt
Matplotlib
matplotlib.org › devdocs › gallery › images_contours_and_fields › image_annotated_heatmap.html
Annotated heatmap — Matplotlib 3.11.0.dev1672+gaf19f1591 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.
Matplotlib
matplotlib.org › 3.1.1 › gallery › images_contours_and_fields › image_annotated_heatmap.html
Creating annotated heatmaps — Matplotlib 3.1.2 documentation
May 1, 2020 - 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. Parameters ---------- data A 2D numpy array of shape (N, M). row_labels A list or array of length N with the labels for the rows. col_labels A list or array of length M with the labels for the columns. ax A `matplotlib.axes.Axes` instance to which the heatmap is plotted.
GeeksforGeeks
geeksforgeeks.org › data visualization › seaborn-heatmap-with-logarithmic-scale-colorbar
Seaborn Heatmap with Logarithmic-Scale Colorbar - GeeksforGeeks
July 23, 2025 - Here is the complete code to generate a Seaborn heatmap with a logarithmic-scale colorbar using the iris dataset: ... import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import numpy as np import matplotlib.colors as mcolors # Load the iris dataset iris = sns.load_dataset('iris') # Drop the categorical 'species' column iris_numeric = iris.drop(columns=['species']) # Compute the correlation matrix corr_matrix = iris_numeric.corr() # Create the heatmap with a logarithmic color scale plt.figure(figsize=(10, 8)) heatmap = sns.heatmap(corr_matrix, cmap='Blues', annot=True, norm=mcolors.LogNorm()) # Customize the colorbar colorbar = heatmap.collections[0].colorbar colorbar.set_label('Log Scale Colorbar') colorbar.ax.set_ylabel('Logarithmic Scale', rotation=270, labelpad=20) # Display the heatmap plt.title('Seaborn Heatmap with Logarithmic-Scale Colorbar') plt.show()
VizLearn
vizlearn.in › home › matplotlib › images and heatmaps
Images and Heatmaps | VizLearn
August 31, 2026 - Passing centres instead of edges is the common mistake; matplotlib will accept same-sized arrays and shift everything by half a cell. pcolormesh is slower than imshow and much more flexible. For a regular grid, imshow is the right tool. contourf is the third option, drawing filled contour bands rather than cells — appropriate when the underlying field is genuinely continuous and misleading when it is not. vmin and vmax set the values at the ends of the colormap. Without them, each heatmap scales to its own data, exactly like unshared subplot axes.
Data Science Dojo
datasciencedojo.com › home › blog › data visualization › demystifying heatmaps: a comprehensive beginner's guide
Demystifying heatmaps: A comprehensive beginner's guide
For example, choosing a poor color scale or omitting important data points can distort the visual representation of the data. It is important to consider these limitations when deciding whether or not to use a heatmap for visualizing your data. Heatmaps are powerful tools for visualizing data patterns and trends. They find applications in various fields, enabling easy interpretation and analysis of large datasets. Matplotlib and Seaborn offer flexible options to create and customize heatmaps.
Published: January 22, 2026