Image by Leonhard Niederwimmer from Pixabay

How to Make a Histogram with Pandas in a Python-powered Jupyter Notebook

Documentation for creating a Histogram with Python, Pandas and Jupyter notebook.

David Allen
8 min readApr 15, 2022

--

A histogram is a powerful (and quick) way to visualize data in Python, especially if you’re working with Pandas dataframes.

In this tutorial, we’ll create a dataframe from a public API request. Then, I’ll show you how to create a histogram, and then customize that histogram by playing with number of bins, figure size, and x-axis range. We’ll also add axis labels, a title, and some annotations.

Soccer fan? Great. You’ll love this tutorial, as we’ll be using the Fantasy Premier League API as our data source.

Let’s do it.

Table of Contents:

  1. Set up notebook
  2. Get some data
  3. Create dataframe
  4. Plot Histogram
  5. Updating Histogram (bins, size, colors)
  6. Add axis labels and title
  7. Annotation
  8. Adding a vertical span (rectangle) to Histogram

Step 1: Set up notebook

--

--

David Allen
David Allen

Written by David Allen

Documentation and tutorials on Python, Pandas, Jupyter Notebook, and Data Analysis.

No responses yet