Wind-rose visualization
Represent directional measurements such as wind frequency by angle and radial magnitude.
Plotly · Function
px.bar_polar creates an interactive polar bar chart, mapping values radially and categories or angles around the circle. It supports grouping and styling through Plotly Express arguments such as color, templates, and color sequences.
px.bar_polar creates a Plotly figure whose bars use radial values for length and angular values for position. Pass a data frame or column-like inputs, map fields with r and theta, and optionally encode groups or styling through arguments such as color and template.
plotly.express.bar_polar(data_frame=None, r=None, theta=None, color=None, ... )| Name | Type | Description |
|---|---|---|
data_frame | DataFrame-like or column-like data | Data frame or column-like data supplying the observations for the chart; the fetched page's example uses px.data.wind(). |
r | str or array-like | Column or array providing radial bar lengths. |
theta | str or array-like | Column or array providing angular bar positions. |
color | str or array-like | Column or array used to assign bar colors or groups. |
template | str or template | Plotly template name controlling the chart theme. |
color_discrete_sequence | sequence | Color sequence used for discrete groups. |
A Plotly figure containing a polar bar chart.
r and an angular coordinate with theta.color for an additional visual grouping and template for the figure's visual theme.go.Barpolar instead when constructing the lower-level trace directly.import plotly.express as px
fig = px.bar_polar(
px.data.wind(),
r="frequency",
theta="direction",
color="strength",
template="plotly_dark",
)
fig.show()Builds and displays a dark-themed polar bar chart from Plotly's wind dataset.
Represent directional measurements such as wind frequency by angle and radial magnitude.
Compare grouped observations around a circular coordinate system.
Explore circular patterns interactively with hover and Plotly figure controls.
px.bar_polar create, and how are the main data fields mapped?px.bar_polar is Plotly Express's high-level function for producing polar bar charts. The documented example maps frequency to radial size, direction to angular position, and strength to color.
Follow-up: How would you access lower-level polar-bar trace attributes? Use the generated figure's graph-object representation and configure a go.Barpolar trace directly.
Use r for the radial measure and theta for the angular coordinate. A field supplied to color separates or colors observations by a categorical or continuous dimension.
Follow-up: How can you add a custom appearance without changing the data mappings? Pass supported styling arguments such as template or a discrete color sequence.
The result is a Plotly figure, so it can be rendered with fig.show(). Plotly's polar bar documentation also describes the graph-object alternative, go.Barpolar, for direct trace construction.
Follow-up: When would direct trace construction be preferable? Choose it when precise trace-level attributes or figure composition are needed beyond the Express interface.
go.Barpolarpx.data.windplotly.graph_objects.Barpolar