Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Plotly · Function

px.parallel_categories

Creates an interactive parallel categories diagram for multidimensional categorical data. Dimensions become category columns, while ribbons show category combinations and their relative frequencies.

How it works

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.

Syntax

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)

Parameters

NameTypeDescription
data_frameDataFrame or array-likeData frame containing the categorical variables and optional values used to construct the figure.
dimensionslist of str or array-likeColumns or data arrays used as categorical dimensions.
countsstr or array-likeValues representing the frequency of each category combination.
colorstr or array-likeColumn or values used to color the ribbons.
labelsdictMapping from source column names to displayed labels.
dimensions_max_cardinalityintMaximum cardinality used for automatic dimension selection.

Returns

A plotly.graph_objects.Figure containing the parallel categories diagram.

Key points

  • The chart is intended for exploring multiple categorical variables together.
  • Every dimension becomes a column, and each category is represented by a rectangle.
  • Ribbons connect category combinations, with thickness conveying how often each combination occurs.
  • Use counts when the data already contains frequencies for category combinations instead of one row per observation.
  • Ribbon color can be set directly through the underlying line.color property.

Common mistakes

  • Without an explicit dimensions list, only columns with fewer than 50 unique values are included by default.
  • Use dimensions or change dimensions_max_cardinality when the default column-selection rule is unsuitable.

Example: Categorical dimensions with color

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.

When to use it

Compare category combinations

Exploring multidimensional categorical data

Show weighted flows with counts

Visualizing pre-aggregated category frequencies

Rename dimensions with labels

Improving chart readability

Interview questions

QWhat visualization does px.parallel_categories create?

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.

QHow do you control the dimensions and their displayed names?

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.

QHow can frequency and ribbon appearance be customized?

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.express
  • parallel_categories
  • parallel_coordinates
  • dimensions
  • counts
  • line.color
  • category_orders

Source: Parallel Categories Diagram in Python - Plotly. Checked 2026-10-15.