Matrix exploration
Visualize a two-dimensional numerical matrix as colored cells.
Plotly · Class
go.Heatmap creates an interactive Cartesian heatmap from two-dimensional values, rendering them as colored rectangular tiles. Add it to a go.Figure and customize coordinates, colors, smoothing, and the color bar.
go.Heatmap is a low-level graph-object trace for displaying two-dimensional numerical data as colored rectangular tiles. Supply the matrix through z, optionally provide x and y coordinates, and configure visual encoding with attributes such as colorscale, color-bar settings, and smoothing.
go.Heatmap(z=None, x=None, y=None, **kwargs)go.Heatmap when Plotly Express does not provide enough starting-point flexibility.px.imshow() supports both heatmaps and full-color images, making it a higher-level alternative.colorscale attribute for mapping values to colors.colorbar attributes.zmid.px.imshow() is an alternative for creating heatmaps.import plotly.graph_objects as go
fig = go.Figure(go.Heatmap(
z=[[1,20,30],[20,1,60],[30,60,1]],
colorscale="Viridis"
))
fig.show()Creates a heatmap trace from a two-dimensional z-value array and renders it in a Plotly figure.
Visualize a two-dimensional numerical matrix as colored cells.
Display model or classification scores across a two-dimensional grid.
Show a single-channel image as a heatmap.
go.Heatmap represent?go.Heatmap is a graph-object trace that maps a two-dimensional z array to colored rectangular tiles. It can be placed in a go.Figure and displayed with fig.show().
Follow-up: How would you choose between this and px.imshow()? Use go.Heatmap when direct trace-level control is useful; use px.imshow() as the higher-level heatmap interface.
The z matrix supplies the heatmap values. Optional x and y values define the coordinates associated with its columns and rows.
Follow-up: How can the displayed colors be controlled? Set the trace's colorscale; related color-bar attributes can also be configured through colorbar.
A heatmap can be added as go.Heatmap(...) data in a go.Figure. The resulting figure can then be rendered with fig.show().
Follow-up: What alternative trace is suitable for multichannel image data? The documentation identifies go.Image; for single-channel images, it recommends go.Heatmap.
plotly.express.imshowgo.Imagego.Contourcolorscalecolorbar