{ "cells": [ { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "%config InlineBackend.figure_format = 'retina'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Two Dimensional Histograms\n", "\n", "## Introduction" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Two-dimensional histograms function in much the same way as one-dimensional histograms, however, instead of having the bins over which you're counting be defined by edges along a single access, bins exist in two dimensions and are defined jointly across multiple axes. Take a look at the figure below, we have two axes for which each data point, in green, in plotted. Both the x and y axes are each divided up into bins with edges at 0, 0.25, 0.5, 0.75, and 1. For each grid cell, we count how many samples fall into the bin and that is the value that we plot in the histogram." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simple example\n", "\n", "Let's walk through a simple example. We'll create some sample data and start by scatter plotting the samples. Let's take a dataset where each data point represents a penguin and two measurements of that penguin: the length of its bill and the length of its flipper. Let's load the data" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | bill_length_mm | \n", "flipper_length_mm | \n", "
---|---|---|
0 | \n", "39.1 | \n", "181 | \n", "
1 | \n", "39.5 | \n", "186 | \n", "
2 | \n", "40.3 | \n", "195 | \n", "
3 | \n", "36.7 | \n", "193 | \n", "
4 | \n", "39.3 | \n", "190 | \n", "
... | \n", "... | \n", "... | \n", "
337 | \n", "47.2 | \n", "214 | \n", "
338 | \n", "46.8 | \n", "215 | \n", "
339 | \n", "50.4 | \n", "222 | \n", "
340 | \n", "45.2 | \n", "212 | \n", "
341 | \n", "49.9 | \n", "213 | \n", "
342 rows × 2 columns
\n", "