Introduction to Seaborn
1. Introduction to Seaborn
Hello! Welcome to this introductory course on Seaborn!2. What is Seaborn?
Seaborn is a powerful Python library for creating data visualizations. It was developed in order to make it easy to create the most common types of plots. The plot shown here can be created with just a few lines of Seaborn code.3. Why is Seaborn useful?
This is a picture of a typical data analysis workflow. Data visualization is often a major component of both data exploration and communicating results, so Seaborn will be very useful there.4. Advantages of Seaborn
There are several tools that can be used for data visualization, but Seaborn offers several advantages. First, Seaborn's main purpose is to make data visualization easy. It was built to automatically handle a lot of complexity behind the scenes. Second, Seaborn works extremely well with pandas data structures. pandas is a Python library that is widely used for data analysis. Finally, it's built on top of Matplotlib, another Python visualization library. Matplotlib is extremely flexible, but this flexibility often comes with added complexity. Seaborn gives you access to Matplotlib's powerful features when you need them, while keeping your code simple by default.5. Getting started
To get started, we'll need to import the Seaborn library. The line "import seaborn as sns" will import Seaborn as the conventionally used alias "sns". Why sns ? The Seaborn library was apparently named after a character named Samuel Norman Seaborn from the television show "The West Wing" - thus, the standard alias is the character's initials ("sns"). We also need to import Matplotlib, which is the library that Seaborn is built on top of. We do this by typing "import matplotlib.pyplot as plt". "plt" is the alias that most people use to refer to Matplotlib, so we'll use that here as well.6. Example 1: Scatter plot
Let's now dive into an example to illustrate how easily you can create visualizations using Seaborn. Here, we have data for 10 people consisting of lists of their heights in inches and their weights in pounds. Do taller people tend to weigh more? You can visualize this using a type of plot known as a scatter plot, which you'll learn more about later in the course. Use "sns dot scatterplot()" to call the scatterplot function from the Seaborn library. Then specify what to put on the x- and y-axes. Finally, call the "plt dot show()" function from Matplotlib to show the scatterplot. This plot shows us that taller people tend to have a higher weight.7. Example 2: Create a count plot
How many of our observations of heights and weights came from males vs. females? You can use another type of plot - the count plot - to investigate this. Count plots take in a categorical list and return bars that represent the number of list entries per category. Use the "countplot()" function and provide the list of every person's gender. This count plot shows that out of the 10 observations we had in our height and weight scatter plot, 6 were male and 4 were female.8. Course Preview
Now, those were a couple of simple examples. Throughout this course, you'll learn to create more complex visualizations, such as those shown here. More importantly, you'll learn when to use each type of visualization in order to most effectively extract and communicate insights using data.9. Let's practice!
We're excited to explore Seaborn with you throughout this course. For now, let's practice what you've just learned!Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.