Python Tutorial: Highlighting data

Learn to highlight specific data points in Python visualizations using color vectors instead of overlaying plots. Using an EPA air-pollution dataset from 11 U.S. cities, the instructor shows how list comprehension lets you programmatically flag outliers and focus attention while keeping the full dataset visible.
Chapters
Welcome. In this course, you will learn how to use Python to craft compelling and efficient data visualizations. First, a tiny bit about me. I have had the pleasure of working as a data scientist and visualizer at places like Johns Hopkins Data Science Lab, the New York Times, and Vanderbilt University. My work focuses on building visualizations for large, complex data sets and model results why is Data Visualization a crucial component of data science? If you've decided to take this course already, you probably don't need me to explain to you the virtues of data visualization. But for the sake of completeness, data visualization helps you take raw data and results coming out of your data science workflow and turns them into tactile and intuitive physical representations. The improvements brought by data visualization can be purely cosmetic, such as converting a simple table of results to a nicer looking chart, or completely necessary for understanding the data, such as visualizing geographic patterns in thousands of geolocated data points. To make the visualizations in this course, we will use a combination of matplotlib and Seaborn to get the most out of this course. You should be familiar with these packages along with basic data manipulation with Pandas. The prerequisite courses for this course are fantastic resources for gaining these skills if you don't already have them. Just because this course is taught with a few specific packages doesn't mean the lessons aren't valuable to users of other tools short of specific methods to perform some actions. The techniques and best practices taught in this course can be applied in your chosen data science platform, such as R spreadsheets or any other of the myriad of tools available throughout the first three chapters. In this course, we will use a fascinating data set from the EPA on pollution levels across the United States. Each row of the data contains the maximum observed air pollution values for four different carbon monoxide, nitrogen dioxide, ozone, and sulfur dioxide. There is data for 11 cities across the United States with data for every day of the year for 2014-2016. Now, on to visualization techniques. The first technique we're going to talk about is simple and is often extremely effective, highlighting specific data points to draw attention to them. Often when you display a lot of data to an audience, you get caught in a conundrum. You want to show all of your data, but you also want people to focus on a specific, interesting point or set of points. The easiest way to show all of the data is to do just that. Plot all of the data points. But how do you avoid a specific point of interest getting lost, like in the scatter of no two against SO two values the simplest solution to this problem is to highlight Here we see how we use a Python list comprehension to improve the plot from the previous slide by adding a highlight to our point of interest, in this case the point corresponding to the 38th day of the year. To highlight a point in Seaborn or matplotlib, we supply our plotting function with a vector of colors corresponding to each row of our data, making a vector with uniform colors for every point except for the ones we want to highlight. We can see our specific point clearly now. This point could be a particularly interesting outlier, or more frequently it may represent something important outside of the data visualization, such as the point corresponding to your company in the midst of its competitors. Those familiar with matplotlib may ask why we aren't just drawing a second scatter plot of just our highlighted points. By using an array based method, we can easily add more highlights to our plot or generate the highlights programmatically. Okay, let's get to making some highlighted plots with our.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







