Python Tutorial: Introduction to Seaborn

Chris Moffitt introduces Seaborn, a Python library built on Matplotlib and Pandas that creates statistical visualizations with minimal code. A simple example: plotting wine alcohol content with Seaborn's distplot automatically adds a Gaussian kernel density estimate and polished styling, compared to basic Matplotlib histograms.
Chapters
Welcome to this introduction to Seaborn. My name is Chris Moffitt and I will be your instructor for this course. I have been using python for over 10 years and I'm currently the creator of the popular blog Practical Business Python. I'm excited to show you how to effectively use the Seaborn library for creating insightful visualizations. The Python visualization landscape is complex and and it can be challenging to find the right tool for the right job. Before we discuss Seaborn in detail, it is helpful to understand where it stands in this landscape. This illustration is from Jake Vander PLAAS PYCON 2017 presentation on the visualization landscape in Python and highlights the complex ecosystem. The key point is that matplotlib is a foundational library used by many visualization tools, including Seaborn. Matplotlib is a robust library that can support building many types of visualization. Seaborn uses it to construct statistical visualizations. When working with Seaborn, it is helpful to understand some of the underlying matplotlib constructs. This brief example shows how to plot a column in a Pandas dataframe as a histogram. This specific example includes information about the alcohol content of several different types of Portuguese wines. If you do not understand this code example, you may want to review some introductory Python courses. The rest of this course will assume you understand basic Python and Pandas usage. Pandas is one of the most important Python libraries for manipulating and analyzing data. In addition to providing powerful data manipulation tools, Pandas supports basic data plotting functions. The actual API is consistent with other Pandas functions, so it is a very useful tool. The plotting is carried out by matplotlib, so the resulting output looks very similar to the pure matplotlib output. This functionality is very useful when you need to quickly look at data that is already in a data frame. Seaborn integrates with the rest of the Python data science landscape by leveraging matplotlib and integrating with Pandas. In this example, a plot similar to a histogram can be created using Seaborn's DIST plot function. The resulting output looks like a histogram but actually is a Gaussian kernel density estimate or kde. In the next slide we will compare this output to the PANDAS generated histogram. This relatively simple example is is illustrative of how to use seaborn. The code is simple but can be used for powerful data analysis. In addition to the analysis, it makes reasonable assumptions about colors and other visual elements to make visualizations that look more pleasing than the standard matplotlib plots. Additionally, Seaborn performs statistical analysis on the data to generate the kde. Now it's your turn to try out Seaborne.
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







