
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
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
- Related Articles
- Plot multiple boxplots in one graph in Pandas or Matplotlib
- Drawing multiple legends on the same axes in Matplotlib
- How to plot multiple histograms on same plot with Seaborn using Matplotlib?
- Creating Dictionary using Javascript
- Adding a legend to a Matplotlib boxplot with multiple plots on the same axis
- How to show a bar and line graph on the same plot in Matplotlib?
- How to plot multiple Pandas columns on the Y-axis of a line graph (Matplotlib)?
- Plot a bar using matplotlib using a dictionary
- Generate a graph using Dictionary in Python
- Creating 3D animation using matplotlib
- Creating a graph with date and time in axis labels with Matplotlib
- How to get boxplot data for Matplotlib boxplots?
- How can multiple plots be plotted in same figure using matplotlib and Python?
- Creating a Graph in Javascript
- Creating multiple process using fork() in C

Advertisements