Introduction and Overview

Welcome to this interactive lesson on bar plots and histograms in Python! In this lesson, we will embark on a beautiful data visualization journey. We will focus on constructing bar plots and histograms using Matplotlib. Are you ready? Let's begin!

Building Bar Plots with Matplotlib

A bar plot visually represents categorical data as rectangular bars, the lengths of which are proportional to their respective values. For instance, a bar plot would be the ideal choice if we wanted to visualize a bookstore's sales data, where the categories are book names and the values are sales numbers.

We can build a bar plot using plt.bar function, which takes in two arrays of the same length: category names and values per category.

The resulting plot looks like this:

Building Histograms with Matplotlib: Dataset

Now, let's move on to histograms! Unlike bar plots, histograms are designed for visualizing distributions of continuous, numeric data. In a histogram, bars represent the frequency of data points falling under specific ranges or bins. Let's say we have age data for a city's population for this example.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal