What are parallel coordinates and parallel categories in plotly?

This recipe explains what are parallel coordinates and parallel categories in plotly

Recipe Objective

What are parallel coordinates and parallel categories in plotly, explain with example.

Parallel Coordinates in this 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 this we have to use function "px.parallel_coordinates". Parallel Categories this is useful for visualizin multi-dimensional categorical data. Each variable in the data set is represented by a column of rectangles, where each rectangle corresponds to a discrete value taken on by that variable. The relative heights of the rectangles reflect the relative frequency of occurrence of the corresponding value.

Step 1 - Import the necessary libraries

import plotly.express as px import seaborn as sns

Step 2 - load the Sample data

Sample_data = px.data.iris() Sample_data.head()

Step 3 - Plot the Parallel coordinates graph

fig = px.parallel_coordinates(Sample_data, 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()

Here in the above plot the functions used are:

color - It will consist name of a column in the dataframe, values from this are used to assign color to marks.

labels - this can be dictionary with string keys and string values, the column are used here is for axis titles. The keys of the dictionary should correspond to column names, and the values should correspond to the desired label to be displayed.

color_continuos scale - these are list of string, the strings should valid CSS-color. This list is used to build a continuous color scale when the column denoted by color contains numeric data.

color_continuos_midpoint - computes the bounds of the continuous color scale to have the desired midpoint.

Step 4 - Plot the Parallel categories graph

Sample_data2 = px.data.tips() fig = px.parallel_categories(Sample_data2, color="size", color_continuous_scale=px.colors.sequential.Inferno) fig.show()

What Users are saying..

profile image

Ray han

Tech Leader | Stanford / Yale University
linkedin profile url

I think that they are fantastic. I attended Yale and Stanford and have worked at Honeywell,Oracle, and Arthur Andersen(Accenture) in the US. I have taken Big Data and Hadoop,NoSQL, Spark, Hadoop... Read More

Relevant Projects

Machine Learning Project to Forecast Rossmann Store Sales
In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

Deep Learning Project for Beginners with Source Code Part 1
Learn to implement deep neural networks in Python .

Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

Build Customer Propensity to Purchase Model in Python
In this machine learning project, you will learn to build a machine learning model to estimate customer propensity to purchase.

End-to-End Snowflake Healthcare Analytics Project on AWS-2
In this AWS Snowflake project, you will build an end to end retraining pipeline by checking Data and Model Drift and learn how to redeploy the model if needed

Build Deep Autoencoders Model for Anomaly Detection in Python
In this deep learning project , you will build and deploy a deep autoencoders model using Flask.

Time Series Forecasting Project-Building ARIMA Model in Python
Build a time series ARIMA model in Python to forecast the use of arrival rate density to support staffing decisions at call centres.

End-to-End Speech Emotion Recognition Project using ANN
Speech Emotion Recognition using RAVDESS Audio Dataset - Build an Artificial Neural Network Model to Classify Audio Data into various Emotions like Sad, Happy, Angry, and Neutral

Build a Text Generator Model using Amazon SageMaker
In this Deep Learning Project, you will train a Text Generator Model on Amazon Reviews Dataset using LSTM Algorithm in PyTorch and deploy it on Amazon SageMaker.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.