Custom polar scatter plots
You need direct control over a polar trace beyond Plotly Express.
Plotly · Class
go.Scatterpolar is Plotly's generic polar scatter trace. Pair radial coordinates (r) with angular coordinates (theta) and optionally render markers, lines, or a filled region.
go.Scatterpolar creates a generic polar scatter trace. Supply radial coordinates with r and angular coordinates with theta, then choose trace rendering such as markers, lines, or a filled region.
go.Scatterpolar(r=None, theta=None, mode=None, fill=None, **kwargs)| Name | Type | Description |
|---|---|---|
r | array-like | Radial coordinates for the trace's points; the documentation's examples pass a sequence of numeric values. |
theta | array-like | Angular coordinates for the trace's points; examples use numeric angles or categorical labels. |
mode | string | Controls how the trace is rendered, such as markers or lines. |
fill | string | Controls whether and how the trace area is filled. |
A Plotly Scatterpolar trace object.
plotly.graph_objects when you need a lower-level polar scatter trace.r property contains radial data points, defining each point's distance from the center.theta property contains angular coordinates corresponding positionally to the radial values.import plotly.graph_objects as go
fig = go.Figure(go.Scatterpolar(
r=[1, 5, 2, 2, 3],
theta=['processing cost', 'mechanical properties', 'chemical stability', 'thermal stability', 'device integration'],
fill='toself'
))
fig.update_layout(
polar=dict(radialaxis=dict(visible=True)),
showlegend=False
)
fig.show()Creates a filled radar-style polar trace from radial values and categorical angular labels.
You need direct control over a polar trace beyond Plotly Express.
You want a radar or spider chart with category labels around the angular axis.
You need to compare multiple radial series on one polar figure.
go.Scatterpolar?Use go.Scatterpolar when Plotly Express is not a suitable starting point. Construct it as a trace, commonly with r for radial values and theta for angular coordinates, then place it in a go.Figure.
Follow-up: How would you create a radar chart? Use categorical angular labels and set fill='toself' to close and fill the polygon.
r and theta represent?The r array supplies distances from the polar origin, while theta supplies angular positions. The example documentation combines numeric radial values with numeric degree angles for a marker-only polar scatter.
Follow-up: How can the same trace represent a radar chart? Replace numeric angular positions with category labels and use a closed fill.
A radar chart can be made with a polar chart using categorical angular variables. In the documented example, fill='toself' fills the area enclosed by the trace, and the polar radial axis is made visible through layout configuration.
Follow-up: How can you display more than one radar series? Add multiple go.Scatterpolar traces to the figure, each with its own r values and shared category labels.
plotly.graph_objects.Figurepx.scatter_polarpx.line_polar