Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Creating multiple boxplots on the same graph from a dictionary, using Matplotlib
To create multiple boxplots on the same graph from a dictionary, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Make a dictionary, dict, with two columns.
- Create a figure and a set of subplots.
- Make a box and whisker plot
- Set the xtick labels using set_xticklabels() method
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
data = {'col1': [3, 5, 2, 9, 1], 'col2': [2, 6, 1, 3, 4]}
fig, ax = plt.subplots()
ax.boxplot(data.values())
ax.set_xticklabels(data.keys())
plt.show()
Output

Advertisements
