- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to make a grouped boxplot graph in matplotlib?
To make a grouped boxplot graph in matplotlib, we can take the following steps −
- Import matplotlib.pyplot and seaborn.
- Set the figure size and adjust the padding between and around the subplots.
- Load an example Seaborn dataset from the online repository.
- Make a boxplot with male and female group in a single day.
- To display the figure, use show() method.
Example
import seaborn as sns import matplotlib.pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Import a Seaborn dataset data = sns.load_dataset('tips') # Create a grouped boxplot sns.boxplot(x=data['day'], y=data['total_bill'], hue=data['sex']) plt.show()
Output
It will produce the following output
Advertisements