- 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
How is the Pyplot histogram bins interpreted? (Matplotlib)
To plot histogram bins interpreted with different bins, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Make a list of data to plot in histogram.
Add a subplot to the current figure,nrows=1, ncols=3 and index=1.
Plot a histogram with data; bins is a number.
Add a subplot to the current figure, nrows=1, ncols=3 and index=2.
Plot a histogram with data; bins is an array.
Add a subplot to the current figure, nrows=1, ncols=3 and index=3.
Plot a histogram with data, bins is a string.
Example
import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = [1, 3, 1, 4, 7, 1, 3, 5, 4, 6, 5] plt.subplot(131) plt.hist(data, bins=len(data)) plt.subplot(132) plt.hist(data, bins=[1, 3, 5, 7]) plt.subplot(133) plt.hist(data, bins='stone') plt.show()
Output
- Related Articles
- Getting information for bins in Matplotlib histogram function
- How to make a histogram with bins of equal area in Matplotlib?
- How to have logarithmic bins in a Python histogram?
- How to create a histogram without bins in base R?
- How to zoom subplots together in Matplotlib/Pyplot?
- How do I close all the open pyplot windows (Matplotlib)?
- How to fill the area under a step curve using pyplot? (Matplotlib)
- How to plot collections.Counter histogram using Matplotlib?
- How to plot hexbin histogram in Matplotlib?
- How is JavaScript an interpreted language?
- How can I attach a pyplot function to a figure instance? (Matplotlib)
- How to plot a 2D histogram in Matplotlib?
- What are n, bins and patches in matplotlib?
- How to display the count over the bar in Matplotlib histogram?
- Explain how Python is an interpreted language

Advertisements