{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualizing Quantities\n", "\n", "\n", "\n", "\n", "In this lesson you will explore how to use one of the many available Python libraries to learn how to create interesting visualizations all around the concept of quantity. Using a cleaned dataset about the birds of Minnesota, you can learn many interesting facts about local wildlife.\n", "\n", "## Observe wingspan with Matplotlib\n", "\n", "An excellent library to create both simple and sophisticated plots and charts of various kinds is Matplotlib. In general terms, the process of plotting data using these libraries includes identifying the parts of your dataframe that you want to target, performing any transforms on that data necessary, assigning its x and y axis values, deciding what kind of plot to show, and then showing the plot. Matplotlib offers a large variety of visualizations, but for this lesson, let's focus on the ones most appropriate for visualizing quantity: line charts, scatterplots, and bar plots.\n", "\n", "✅ Use the best chart to suit your data's structure and the story you want to tell.\n", "\n", "* To analyze trends over time: line\n", "* To compare values: bar, column, pie, scatterplot\n", "* To show how parts relate to a whole: pie\n", "* To show distribution of data: scatterplot, bar\n", "* To show trends: line, column\n", "* To show relationships between values: line, scatterplot, bubble\n", "\n", "If you have a dataset and need to discover how much of a given item is included, one of the first tasks you have at hand will be to inspect its values.\n", "\n", "✅ There are very good 'cheat sheets' available for Matplotlib here.\n", "\n", "## Build a line plot about bird wingspan values\n", "\n", "> Note: the data is stored in the root of this repo in the `/data` folder." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Name | \n", "ScientificName | \n", "Category | \n", "Order | \n", "Family | \n", "Genus | \n", "ConservationStatus | \n", "MinLength | \n", "MaxLength | \n", "MinBodyMass | \n", "MaxBodyMass | \n", "MinWingspan | \n", "MaxWingspan | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "Black-bellied whistling-duck | \n", "Dendrocygna autumnalis | \n", "Ducks/Geese/Waterfowl | \n", "Anseriformes | \n", "Anatidae | \n", "Dendrocygna | \n", "LC | \n", "47.0 | \n", "56.0 | \n", "652.0 | \n", "1020.0 | \n", "76.0 | \n", "94.0 | \n", "
1 | \n", "Fulvous whistling-duck | \n", "Dendrocygna bicolor | \n", "Ducks/Geese/Waterfowl | \n", "Anseriformes | \n", "Anatidae | \n", "Dendrocygna | \n", "LC | \n", "45.0 | \n", "53.0 | \n", "712.0 | \n", "1050.0 | \n", "85.0 | \n", "93.0 | \n", "
2 | \n", "Snow goose | \n", "Anser caerulescens | \n", "Ducks/Geese/Waterfowl | \n", "Anseriformes | \n", "Anatidae | \n", "Anser | \n", "LC | \n", "64.0 | \n", "79.0 | \n", "2050.0 | \n", "4050.0 | \n", "135.0 | \n", "165.0 | \n", "
3 | \n", "Ross's goose | \n", "Anser rossii | \n", "Ducks/Geese/Waterfowl | \n", "Anseriformes | \n", "Anatidae | \n", "Anser | \n", "LC | \n", "57.3 | \n", "64.0 | \n", "1066.0 | \n", "1567.0 | \n", "113.0 | \n", "116.0 | \n", "
4 | \n", "Greater white-fronted goose | \n", "Anser albifrons | \n", "Ducks/Geese/Waterfowl | \n", "Anseriformes | \n", "Anatidae | \n", "Anser | \n", "LC | \n", "64.0 | \n", "81.0 | \n", "1930.0 | \n", "3310.0 | \n", "130.0 | \n", "165.0 | \n", "