Parallel Coordinates Plot in Python
How to make parallel coordinates plots in Python with Plotly.
Plotly Studio: Transform any dataset into an interactive data application in minutes with AI. Try Plotly Studio now.
Parallel Coordinates plot with Plotly Express¶
Plotly Express is the easy-to-use, high-level interface to Plotly, which operates on a variety of types of data and produces easy-to-style figures. In a parallel coordinates plot with px.parallel_coordinates, each row of the DataFrame is represented by a polyline mark which traverses a set of parallel axes, one for each of the dimensions. For other representations of multivariate data, also see parallel categories, radar charts and scatterplot matrix (SPLOM).
import plotly.express as px
df = px.data.iris()
fig = px.parallel_coordinates(df, color="species_id", labels={"species_id": "Species",
"sepal_width": "Sepal Width", "sepal_length": "Sepal Length",
"petal_width": "Petal Width", "petal_length": "Petal Length", },
color_continuous_scale=px.colors.diverging.Tealrose,
color_continuous_midpoint=2)
fig.show()
Parallel coordinates are richly interactive by default. Drag the lines along the axes to filter regions.
Select the columns to be represented with the dimensions parameter.
import plotly.express as px
df = px.data.iris()
fig = px.parallel_coordinates(df, color="species_id",
dimensions=['sepal_width', 'sepal_length', 'petal_width',
'petal_length'],
color_continuous_scale=px.colors.diverging.Tealrose,
color_continuous_midpoint=2)
fig.show()
Parallel Coordinates Chart with go.Parcoords¶
import plotly.graph_objects as go
fig = go.Figure(data=
go.Parcoords(
line_color='blue',
dimensions = list([
dict(range = [1,5],
constraintrange = [1,2], # change this range by dragging the pink line
label = 'A', values = [1,4]),
dict(range = [1.5,5],
tickvals = [1.5,3,4.5],
label = 'B', values = [3,1.5]),
dict(range = [1,5],
tickvals = [1,