- ✕This summary was generated using AI based on multiple online sources. To view the original source information, use the "Learn more" links.
Histograms in Matplotlib are a powerful way to visualize the distribution of numerical data. They group data into bins and display the frequency of values within each bin.
Basic Histogram
To create a simple histogram, you only need a 1D array of numbers. You can control the number of bins with the bins parameter.
import matplotlib.pyplot as pltimport numpy as np# Generate random datanp.random.seed(19680801)data = np.random.normal(200, 25, size=100)# Basic histogramplt.hist(data, bins=10)plt.xlabel('Value')plt.ylabel('Frequency')plt.title('Basic Histogram')plt.show()Copied!✕CopyThis will display a histogram with 10 equally spaced bins.
Customizing the Histogram
You can adjust style, density, colors, and bin widths for better visualization.
# Custom histogram with style changesplt.hist(data, bins=20, density=True, histtype='stepfilled',facecolor='g', alpha=0.75)plt.xlabel('Value')plt.ylabel('Probability')plt.title('Styled Histogram')plt.show()Copied!✕CopyHere:
Histograms — Matplotlib 3.10.8 documentation
Generate data and plot a simple histogram # To generate a 1D histogram we only need a single vector of numbers. For a 2D histogram we'll need a second vector. We'll generate both below, and show the …
See results only from matplotlib.orgHistogram Bins, Density, and …
The Matplotlib hist method calls numpy.histogram and plots the results, …
Demo of The Histogram Fun…
Demo of the histogram function's different histtype settings # Histogram with step …
Artist Customization in Box P…
Artist customization in box plots # This example demonstrates how to use the …
Cumulative Distributions
Cumulative distributions # This example shows how to plot the empirical …
Create 3D Histogram of 2D D…
Create 3D histogram of 2D data # Demo of a histogram for 2D data as a bar graph in …
Bihistogram
Download Jupyter notebook: histogram_bihistogram.ipynb Download …
Hist(X)
import matplotlib.pyplot as plt import numpy as np plt.style.use('_mpl-gallery') …
Violin Plot Customization
Violin plot customization # This example demonstrates how to fully customize …
Multiple Histograms Side by …
Multiple histograms side by side # This example plots horizontal histograms of …
Animated Histogram
Use histogram's BarContainer to draw a bunch of rectangles for an animated …
Plotting Histogram in Python using Matplotlib - GeeksforGeeks
Python Histogram Gallery | Dozens of examples with code
This page showcases many histograms built with python, using the most popular libraries like seaborn and matplotlib. Examples start with very simple, beginner …
Matplotlib Histograms - W3Schools
In Matplotlib, we use the hist() function to create histograms. The hist() function will use an array of numbers to create a histogram, the array is sent into the …
Plot a Histogram in Python Using Matplotlib
Sep 10, 2025 · In this tutorial, I will show you how to plot a histogram in Python using Matplotlib. I’ll walk you through step-by-step methods, share full code …
How To Make Histograms with Matplotlib in Python?
Aug 5, 2025 · In this comprehensive guide, we’ll walk you through everything you need to know about creating insightful and highly customized histograms with …
Mastering Python Matplotlib Histograms: A Complete Guide
Dec 13, 2024 · Learn how to create and customize histograms using Python Matplotlib's plt.hist (). Master data visualization with clear examples and practical applications.
matplotlib.pyplot.hist — Matplotlib 3.10.8 documentation
Compute and plot a histogram. This method uses numpy.histogram to bin the data in x and count the number of values in each bin, then draws the distribution either …
Matplotlib - Histogram - Online Tutorials Library
In Matplotlib, creating a vertical histogram involves plotting a graphical representation of the frequency distribution of a dataset, with the bars oriented …
Matplotlib.pyplot.hist () in Python - GeeksforGeeks
Mar 18, 2026 · Example 2: In this example, we will create a histogram with different attributes using matplotlib.pyplot.hist () function. We define a specific set of …