Python:Plotly .Parcoords()

Anonymous contributor's avatar
Anonymous contributor
Published Mar 24, 2025
Contribute to Docs

In Plotly, the .Parcoords() function under the graph_objects module creates a parallel coordinates plot representing multivariate data. Each row of the given dataset is plotted as a polyline between the parallel axes.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
    • With Certificate
    • Beginner Friendly.
      24 hours

Syntax

plotly.graph_objects.Parcoords(line=None, dimensions=None, ...)
  • line: A dictionary of class properties to be used.
  • dimensions: A list of dictionaries with class properties to be used.

Note: The ellipsis (…) in the syntax indicates that there are additional optional parameters beyond those listed here to customize the parcoords plot.

Example

This code creates a parallel coordinates plot using the .Parcoords() function:

import plotly.graph_objects as go
import plotly.express as px
import pandas as pd
# Load the Iris dataset
df = px.data.iris()
# Create a parallel coordinates plot
fig = go.Figure(data=
go.Parcoords(
line = dict(color = df['species_id'],
colorscale = [[0, 'gold'], [0.5, 'teal'], [1.0, 'purple']]),
dimensions = list((
dict(range = [0,8],
constraintrange = [4,8],
label = 'Sepal Length', values = df['sepal_length']),
dict(range = [0,8],
label = 'Sepal Width', values = df['sepal_width']),
dict(range = [0,8],
label = 'Petal Length', values = df['petal_length']),
dict(range = [0,8],
label = 'Petal Width', values = df['petal_width'])
))
)
)
# Display the plot
fig.show()

In the above code, the data in the DataFrame can be accessed through the dimensions class and the lines of the parallel coordinates plot can be adjusted with the line class properties.

The above code generates the following output:

Output for the above code

All contributors

Contribute to Docs

Learn Python:Plotly on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
    • With Certificate
    • Beginner Friendly.
      24 hours