{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Highlighting your data\n", "> How do you show all of your data while making sure that viewers don't miss an important point or points? Here we discuss how to guide your viewer through the data with color-based highlights and text. We also introduce a dataset on common pollutant values across the United States. This is the Summary of lecture \"Improving Your Data Visualizations in Python\", via datacamp.\n", "\n", "- toc: true \n", "- badges: true\n", "- comments: true\n", "- author: Chanseok Kang\n", "- categories: [Python, Datacamp, Visualization]\n", "- image: images/annotations.png" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import seaborn as sns\n", "\n", "plt.rcParams['figure.figsize'] = (10, 5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Highlighting data\n", "- Why Data Visualization?\n", " - Raw data $ \\rightarrow $ tactile representations\n", " - Sometimes purely cosmetic\n", " - Sometimes essential to understanding data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Hardcoding a highlight\n", "You are working with the city of Houston to look at the relationship between sulfur dioxide ($SO_2$) and nitrogen dioxide ($NO_2$) pollution, specifically, pollution in the most recent year data was collected (2014). You have singled out a particularly bad day, November 26th, where there was a bad spike in the $SO_2$ levels. To draw the viewers attention to this bad day, you will highlight it in a bright orangish-red and color the rest of the points gray." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | city | \n", "year | \n", "month | \n", "day | \n", "CO | \n", "NO2 | \n", "O3 | \n", "SO2 | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "Cincinnati | \n", "2012 | \n", "1 | \n", "1 | \n", "0.245 | \n", "20.0 | \n", "0.030 | \n", "4.20 | \n", "
1 | \n", "Cincinnati | \n", "2012 | \n", "1 | \n", "2 | \n", "0.185 | \n", "9.0 | \n", "0.025 | \n", "6.35 | \n", "
2 | \n", "Cincinnati | \n", "2012 | \n", "1 | \n", "3 | \n", "0.335 | \n", "31.0 | \n", "0.025 | \n", "4.25 | \n", "
3 | \n", "Cincinnati | \n", "2012 | \n", "1 | \n", "4 | \n", "0.305 | \n", "25.0 | \n", "0.016 | \n", "17.15 | \n", "
4 | \n", "Cincinnati | \n", "2012 | \n", "1 | \n", "5 | \n", "0.345 | \n", "21.0 | \n", "0.016 | \n", "11.05 | \n", "