

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Plot multiple boxplots in one graph in Pandas or Matplotlib
To plot multiple boxplots in one graph in Pandas or Matplotlib, we can take the following steps −
Steps
Set the figure size and adjust the padding between and around the subplots.
Make a Pandas data frame with two columns.
Plot the data frame using plot() method, with kind='boxplot'.
To display the figure, use show() method.
Example
import pandas as pd import numpy as np from matplotlib import pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Pandas dataframe data = pd.DataFrame({"Box1": np.random.rand(10), "Box2": np.random.rand(10)}) # Plot the dataframe ax = data[['Box1', 'Box2']].plot(kind='box', title='boxplot') # Display the plot plt.show()
Output
It will produce the following output −
- Related Questions & Answers
- Creating multiple boxplots on the same graph from a dictionary, using Matplotlib
- Plot a Line Graph for Pandas Dataframe with Matplotlib?
- How to plot multiple Pandas columns on the Y-axis of a line graph (Matplotlib)?
- How to plot a bar graph in Matplotlib from a Pandas series?
- How to plot multiple horizontal bars in one chart with matplotlib?
- Plot multiple time-series DataFrames into a single plot using Pandas (Matplotlib)
- How do I plot multiple X or Y axes in Matplotlib?
- Plot multiple columns of Pandas dataframe on the bar chart in Matplotlib
- How to plot multiple graphs in Matplotlib?
- How to plot a high resolution graph in Matplotlib?
- Python - Plot a Pandas DataFrame in a Line Graph
- Frequency plot in Python/Pandas DataFrame using Matplotlib
- Python Pandas - Plot multiple data columns in a DataFrame?
- How to plot one single data point in Matplotlib?
- How to plot a line graph from histogram data in Matplotlib?
Advertisements