Compare category combinations
Exploring multidimensional categorical data
Plotly · Function
Creates an interactive parallel categories diagram for multidimensional categorical data. Dimensions become category columns, while ribbons show category combinations and their relative frequencies.
The function builds a parallel categories diagram from a data frame. Columns become categorical dimensions, category combinations are connected by ribbons, and optional counts or color settings control ribbon weighting and appearance.
plotly.express.parallel_categories(data_frame=None, dimensions=None, color=None, labels=None, color_continuous_scale=None, color_continuous_midpoint=None, range_color=None, color_discrete_sequence=None, color_discrete_map=None, dimensions_max_cardinality=50, counts=None, title=None, template=None, width=None, height=None)| Name | Type | Description |
|---|---|---|
data_frame | DataFrame or array-like | Data frame containing the categorical variables and optional values used to construct the figure. |
dimensions | list of str or array-like | Columns or data arrays used as categorical dimensions. |
counts | str or array-like | Values representing the frequency of each category combination. |
color | str or array-like | Column or values used to color the ribbons. |
labels | dict | Mapping from source column names to displayed labels. |
dimensions_max_cardinality | int | Maximum cardinality used for automatic dimension selection. |
A plotly.graph_objects.Figure containing the parallel categories diagram.
import plotly.express as px
df = px.data.tips()
fig = px.parallel_categories(
df,
dimensions=["sex", "smoker", "day"],
color="size",
color_continuous_scale=px.colors.sequential.Inferno,
labels={"sex": "Payer sex", "smoker": "Smokers at the table", "day": "Day of week"},
)
fig.show()Creates a parallel categories figure from selected categorical columns, colors ribbons using a numeric column, applies a continuous color scale, and displays the result.
Exploring multidimensional categorical data
Visualizing pre-aggregated category frequencies
Improving chart readability
It creates a parallel categories diagram for multidimensional categorical data. Each variable appears as a column of category rectangles, and ribbons connect category combinations with widths representing their occurrence frequency.
Follow-up: How would you restrict which variables appear? Pass the desired column names through dimensions, rather than relying on automatic selection.
Use dimensions to specify the categorical columns explicitly. labels can map source column names to display labels in the resulting figure.
Follow-up: What happens if dimensions is omitted? Columns with cardinality below the default threshold are selected automatically; dimensions_max_cardinality can alter that threshold.
If combination frequencies are already known, provide them through counts. Ribbon coloring can be controlled with color and a continuous color scale, while lower-level ribbon color is represented by line.color.
Follow-up: When should counts be used? Use them when each category combination is pre-aggregated and the supplied values represent its frequency.
plotly.expressparallel_categoriesparallel_coordinatesdimensionscountsline.colorcategory_orders