{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Plotting Zoo: multiple ways to visualize the same set of data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "One of the strengths and challenges of plotting data in Python with matplotlib is the sheer quantity of ways that you can plot something. Let's show that in action by plotting the same dataset in several ways. We'll start by making the most basic version of that type of plot, then explore some variations of some of those plots.\n", "\n", "We'll use a dataset showing employment statistics of the two 5 sectors of the United States economy: health care and social assistance, state and local government, retail trade, manufacturing, and accommodation and food services for the years of 2018-2022. In 2022 these 5 sectors collectively represented just over 50% of all employment in the United States according to the data provided from the [Bureau of Economic Analysis](https://apps.bea.gov/iTable/?reqid=19&step=2&isuri=1&1921=survey&_gl=1*osw51v*_ga*Mzc1MTY0ODM4LjE3MjE1NjgyODg.*_ga_J4698JNNFT*MTcyMTU2ODI4OC4xLjAuMTcyMTU2ODI4OC42MC4wLjA.#eyJhcHBpZCI6MTksInN0ZXBzIjpbMSwyLDNdLCJkYXRhIjpbWyJDYXRlZ29yaWVzIiwiU3VydmV5Il0sWyJOSVBBX1RhYmxlX0xpc3QiLCIxOTciXV19) out of the total 143 million full-time employees. The units in the data are thousands of full-time employees.\n", "\n", "## A table\n", "\n", "The most basic data visualization of them all may not even be one that you would consider a visualization, but it is indeed a visual representation of the data, and that's a table. Fortunately, pandas allows us to easily make a table:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Sector | \n", "2018 | \n", "2019 | \n", "2020 | \n", "2021 | \n", "2022 | \n", "
---|---|---|---|---|---|---|
0 | \n", "Health care and social assistance | \n", "18255 | \n", "18615 | \n", "18179 | \n", "18522 | \n", "18904 | \n", "
1 | \n", "State and local government | \n", "16373 | \n", "16553 | \n", "16017 | \n", "15928 | \n", "16153 | \n", "
2 | \n", "Retail trade | \n", "13809 | \n", "13722 | \n", "13044 | \n", "13566 | \n", "13704 | \n", "
3 | \n", "Manufacturing | \n", "12387 | \n", "12526 | \n", "11844 | \n", "12087 | \n", "12523 | \n", "
4 | \n", "Accommodation and food services | \n", "11342 | \n", "11591 | \n", "8986 | \n", "9897 | \n", "10962 | \n", "