Exploring the Palmer Penguins
DS 2023 | Communicating with Data
Overview¶
The Penguins dataset describes 333 penguins from three species, measured on islands near Palmer Station, Antarctica.
This notebook presents a simple example of a dashboard to explore the dataset.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import ipywidgets as widgets
from ipywidgets import interact, interactive
penguins = sns.load_dataset('penguins').dropna()
measure_cols = ['bill_length_mm', 'bill_depth_mm', 'flipper_length_mm', 'body_mass_g']How do the species differ in size?¶
Pick a measure and a number of bins.
Each species gets its own histogram, drawn on top of the others.
@interact(measure=measure_cols, bins=(5, 50, 5))
def plot_hist(measure='flipper_length_mm', bins=20):
(penguins
.pivot(columns='species', values=measure)
.plot.hist(bins=bins, alpha=0.5, figsize=(5, 3.5), title=measure))
plt.show()Loading...
Flipper length separates Gentoo penguins from the other two species almost completely.
Bill length does a better job of separating Adélie from Chinstrap.
Which measure overlaps the most?
Which measures go together?¶
Pick two measures to plot against each other.
@interact(x=measure_cols, y=measure_cols)
def plot_scatter(x='bill_length_mm', y='bill_depth_mm'):
penguins.plot.scatter(x=x, y=y, c='species', figsize=(5, 3.5))
plt.show()Loading...
With bill length on x and bill depth on y, the three species form three separate clouds.
Neither measure alone can do that.