- Trending Categories
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
Matplotlib – Make a Frequency histogram from a list with tuple elements in Python
To make a frequency histogram from a list with tuple elements in Python, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Make a list of tuples, data.
- Make lists of frequency and indices, after iterating the data.
- Make a bar plot usig bar() method.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True data = [("a", 1), ("c", 3), ("d", 4), ("b", 2), ("e", 7), ("f", 3), ('g', 2)] ind = [] fre = [] for item in data: ind.append(item[0]) fre.append(item[1]) plt.bar(ind, fre) plt.show()
Output
It will produce the following output −
- Related Articles
- How to make a histogram from a list of data in Matplotlib?
- Setting a relative frequency in a Matplotlib histogram
- How to plot a histogram using Matplotlib in Python with a list of data?
- Python - Join tuple elements in a list
- How to make a histogram with bins of equal area in Matplotlib?
- Plot a histogram with colors taken from colormap in Matplotlib
- Python - Plot a Histogram for Pandas Dataframe with Matplotlib?
- List frequency of elements in Python
- Python – Restrict Elements Frequency in List
- Python – Concatenate Rear elements in Tuple List
- Create a tuple from string and list in Python
- How to make a log histogram in Python?
- Python – Fractional Frequency of elements in List
- Plotting a histogram from pre-counted data in Matplotlib
- Count occurrence of all elements of list in a tuple in Python

Advertisements