Python Data Visualization Transcripts
Chapter: Seaborn
Lecture: Displot relplot and facetting

Login or purchase this course to watch this video and the rest of the course contents.
0:00 As we continue to explore how to use Seaborn. I've created another notebook to import EPA fuel economy summary data.
0:10 In this case I'm going to continue to use the dark grid style. So let's walk through an example of the displot.
0:20 In this example we passed our data frame we'll use the fuel cost along the X axis past the year as the hue.
0:27 And I'm also passing aspect equals 2.5 to spread this out. So it takes up more space and is a little more appealing.
0:36 This is just one of the many options that's available to adjust the size of your
0:41 seaborn plots. And I want to point this out while we're going through this.
0:45 So let me give another example let's say we want to do a similar plot instead of looking at it by each individual year because there's a lot of years.
0:56 Maybe we do the date range instead. Now we have a different view. We can see that the dates from 2000 to 2010 tend to cost a little bit
1:10 more than the more recent models. Now if we want to vary the data by column let's let's kind of keep similar
1:19 sort of data will continue to look at the fuel cost. But let's change it instead of using hue let's pass column and I don't really need
1:32 the aspect ratio for this visualization and now what we've done is now we have broken
1:39 the plot into two different plots by date range and this is a really nice way to just quickly go back and forth between the visualizations and see.
1:50 Is this one a little easier to understand than this one. And I would say in this case I do like having the two plots side by
1:58 side versus the plots with different colors. Now I'll show an example of,
2:04 let's say we'll use a similar plot this time will change the kind and will also change the row. So here I did column equal state range.
2:16 Now I'll do row equal state range and it will do what you expect added in two different rows. And in this case I'm using a
2:24 'kde'. So I get that that smooth curve versus the individual bars of the dis plot. And if I want to continue this I can take a look at a
2:35 similar approach for the relationship plot. So let's do a relationship plot and will pass the cylinders and combined 08,
2:45 what if I want to take this and add a color. So we'll use hue specify the drive column.
2:56 Now we have a single plot but you can see the four wheel drive versus two
3:00 wheel drive where they end up in their combined fuel economy as well as the cylinders
3:05 in these different vehicles. And if I want to do a similar approach. Now, just like I did with the catplot with the relationship plot and maybe
3:17 I'll clean this up a little bit and maybe I'll add a column to spread my
3:24 data across the different columns. I'll keep the kind equal scatter and now I have
3:31 two plots. The date ranges change across each column and I continue to have the
3:37 color. So this will be 4 wheel drive and two wheel drive vehicles from 2011 to 2020 and this is from 2000 to 2010 if I want to,
3:48 maybe the scatter plot isn't the best way to look at it. So let's keep everything else the same.
3:55 But let's change the kind to line and now we can see the two different plots and what the variations are by year.
4:06 It gives us a little bit more insight into what those relationships are over time, as well as between the cylinders and the combined fuel economy.
4:18 But what I really like about this is when I'm working with Seaborn, I can start with one type of plot and easily change it to different plots by
4:27 changing the kind by varying the data on the columns and the rows and changing the
4:34 hue to get the data just in the way I need it to answer my business problem.

Talk Python's Mastodon Michael Kennedy's Mastodon