Isovalue mapping
Visualize a scalar field sampled on a rectangular grid.
Plotly · Class
go.Contour creates an interactive 2D contour plot from a numerical z array. Optional one-dimensional x and y arrays specify the horizontal and vertical coordinates.
go.Contour is a graph-object trace for visualizing interpolated isovalue lines from a two-dimensional numeric z array. Supply one-dimensional x and y coordinate arrays when the grid axes need explicit values, then place the trace in a figure and display it.
go.Contour(z=z, x=x, y=y, contours_coloring="lines", showscale=False)| Name | Type | Description |
|---|---|---|
z | array-like | Two-dimensional numerical array whose values determine the contour levels. |
x | array-like | One-dimensional values for the horizontal axis. |
y | array-like | One-dimensional values for the vertical axis. |
contours_coloring | string | Controls how contours are colored, such as with lines or a heatmap. |
showscale | boolean | Controls whether the color scale is displayed. |
A Plotly graph-object contour trace, intended to be supplied as figure data.
z array.x coordinate array defines positions along the horizontal axis.y coordinate array defines positions along the vertical axis.contours_coloring to "lines" when the visualization should emphasize contour boundaries without heatmap-style filling.showscale=False.z array; the trace represents interpolated isovalue lines rather than arbitrary point data.x and y arrays describing the horizontal and vertical axes.import plotly.graph_objects as go
fig = go.Figure(go.Contour(
z=[[10, 10.625, 12.5], [5.625, 6.25, 8.125], [2.5, 3.125, 5.0]],
x=[-9, -6, -5],
y=[0, 1, 4],
contours_coloring="lines"
))
fig.show()Creates and displays a contour trace from a two-dimensional numeric array, with optional one-dimensional coordinates and line-only coloring.
Visualize a scalar field sampled on a rectangular grid.
Display a filled representation of numerical intensity across two dimensions.
Overlay contour information on a subplot or another trace.
x and y represent?go.Contour renders contour lines derived from a two-dimensional numerical z array. It can also accept one-dimensional x and y arrays to define the horizontal and vertical coordinates.
Follow-up: How would you show only isolines instead of a filled contour map? Set contours_coloring to "lines".
Create the trace with go.Contour, pass it to go.Figure, and call fig.show() to render the interactive chart. The trace can be configured for line-only coloring or other contour presentations.
Follow-up: How can multiple contour representations be composed? Add multiple contour traces to the same figure, configuring each trace independently.
A contour plot uses interpolated lines of equal values from the two-dimensional z array. Explicit x and y coordinates let the trace map those values onto specified horizontal and vertical axes.
Follow-up: What should be checked when coordinates do not align with the grid? Verify that the coordinate arrays are one-dimensional and correspond to the dimensions of z.
go.Heatmapplotly.graph_objects.Figurecontour plots