How to make grouped box plot in plotly?

This recipe helps you make grouped box plot in plotly

Recipe Objective

How to make grouped box plot in plotly?

Grouped Box plot this is a plot where the categories are being organized in groups or sub-groups, the plotting can be done from the both indexed data and raw data. It is very useful in understanding and also takes very less space in layout.

Step 1 - Import library

import plotly.graph_objects as go

Step 2 - Take Sample data

x_axis = ['a1','a1','a1','b1','b1','b1'] y1 = [1,3,5,7,9,11] y2 = [2,4,6,8,10,12] y3 = [3,6,9,12,15,18]

Step 3 - Plot graph

fig = go.Figure() fig.add_trace(go.Box(y=y1, x=x_axis, name="First", marker_color= "red")) fig.add_trace(go.Box(y=y2, x=x_axis, name="Second", marker_color= "green")) fig.add_trace(go.Box(y=y3, x=x_axis, name="Third", marker_color= "yellow")) fig.update_layout(boxmode="group")

What Users are saying..

profile image

Savvy Sahai

Data Science Intern, Capgemini
linkedin profile url

As a student looking to break into the field of data engineering and data science, one can get really confused as to which path to take. Very few ways to do it are Google, YouTube, etc. I was one of... Read More

Relevant Projects

Linear Regression Model Project in Python for Beginners Part 2
Machine Learning Linear Regression Project for Beginners in Python to Build a Multiple Linear Regression Model on Soccer Player Dataset.

Mastering A/B Testing: A Practical Guide for Production
In this A/B Testing for Machine Learning Project, you will gain hands-on experience in conducting A/B tests, analyzing statistical significance, and understanding the challenges of building a solution for A/B testing in a production environment.

Build CNN Image Classification Models for Real Time Prediction
Image Classification Project to build a CNN model in Python that can classify images into social security cards, driving licenses, and other key identity information.

Build an AI Quiz Generator from Video with OpenAI API
In this LLM project, you will build a model to automate the transcription of video content and generate interactive quizzes using OpenAI’s Whisper and GPT-4o.

MLOps Project to Build Search Relevancy Algorithm with SBERT
In this MLOps SBERT project you will learn to build and deploy an accurate and scalable search algorithm on AWS using SBERT and ANNOY to enhance search relevancy in news articles.

Learn Hyperparameter Tuning for Neural Networks with PyTorch
In this Deep Learning Project, you will learn how to optimally tune the hyperparameters (learning rate, epochs, dropout, early stopping) of a neural network model in PyTorch to improve model performance.

ML Model Deployment on AWS for Customer Churn Prediction
MLOps Project-Deploy Machine Learning Model to Production Python on AWS for Customer Churn Prediction

Learn to Build an End-to-End Machine Learning Pipeline - Part 1
In this Machine Learning Project, you will learn how to build an end-to-end machine learning pipeline for predicting truck delays, addressing a major challenge in the logistics industry.

Learn How to Build a Linear Regression Model in PyTorch
In this Machine Learning Project, you will learn how to build a simple linear regression model in PyTorch to predict the number of days subscribed.

Hands-On Approach to Master PyTorch Tensors with Examples
In this deep learning project, you will learn how to perform various operations on the building block of PyTorch : Tensors.