Hello everyone and welcome the grid's lecture the seaboard section of the course in this lecture.
We're going to learn how to use sideboards grid's ability to automate subplots based off of features
in our data.
Let's go in and jump to Jupiter note that we get started.
OK here I am at the Jupiter note.
I want to hit that import Seaborn as Asinus called Map plot live in line and then I uploaded the iris
data set and you can do that just by saying S and S thought load underscore data set and then passing
the string Iris and took out the head of this iris dataset is a pretty famous set.
It's basically just measurements of a bunch of different flowers or irises.
And the last cone here on species has three distinct types of values.
So if I go out and say Just enter here and call Iris circuts species we can check out the unique values
here.
And there's three species of flowers possible two there Tosa versicolor or virginica and the other four
columns are just features of the flower such as people weighing or peddling metal with etc..
We're going to see much more of this data set when we talk about machine learning.
But for now let's just go ahead and do a simple pair plot on this data.
So plot is kind of the automated joint plot for the entire data set.
So remember from that distribution what lecture's so we can just pass in the data frame and it will
automatically create this pair plot for us now using seaborne spared great mechanism.
We're actually going to be able to customize this sort of pair plot a lot more control over the actual
plots.
Let's go ahead and show you how we can do that.
I want to go ahead and call hared grid instead of pear plots in paygrade is going to be capital P H
I R Capital G R i.e. r id.
And then your data frame.
So we have period and this just gives us an empty peregrinus.
It takes all the numerical columns and grids them up essentially kind of making the subplots for us
and payr plot is just a simplified version of Peregrym.
So her plot does a lot of the stuff automatically pair grid.
You have to do a little more but it gives you a lot more control.
Let's go in and see how we can use it.
The main way is to set this pair grid equal to a variable and then off of that variable you can map
what type.
So for instance if I want to go ahead and map maybe a scatterplot I can say T-Dog scatter and this will
map a scatterplot to both the upper diagonal the diagonal itself and the lower half.
Now if I want to actually specify what I want on the diagonal upper half and lower half I can specify
that command I say map underscore diag and this will be the diagonal plot.
And we just go ahead and map something to this.
So let's go ahead and map a.
This plots to the entire diagonal and then I'm going to map the upper plots.
We'll go ahead and keep that scatterplot maps just on the upper and then on the lower map underscore
lower.
I can plot some other plot type for instance Katy plot.
All right.
And notice here I'm not closing the princes off of these plots and just passing in the plot function
.
So that's going to map it based off the data that either these Agnel are upper or lower places that
matrix so we can go out and check that out.
This may take a little while to run depending on how fashed computer is but now we can see we have this
sort of grid or a pair plot but we have a lot more control over it.
So they're just being scatter plots of histograms.
Now we can actually choose what plot types we want to map.
And that's just the basic idea behind Peregrym.
Usually we'll just use per plot since it's simpler and gives us most of the information we want.
But if you're ever trying to get a little more customized ability out of the seaboard plots especially
payr plot types things you can use paygrade to do that and then map the whatever specific what types
you want to diagonal upper or lower.
Now let's discuss Fassett grid nerd to discuss Fassett grid and when we go out and clear this and I'm
going to load the tips data set by saying Tipps is equal to Asinus load data sets and then passing the
string tips check out the head of our data set.
All right we have our tips data set that we're familiar with.
Let's go ahead and just show you a very simple example of the Fassett grid by just showing the grid
similar to Peregrym.
I'm going to call you white and zoom in here a little bit.
I want to call it g is equal to asinus.
Thought Fassett grid.
And then Professor Green which you do as you pass in the data.
So you're going to say data is equal to or as the first argument you know to say that equals you just
pasand tips and then you specify what you want the call to be and what you want the road to be.
That is kind of similar to where we're using subplots that what Lyd.
Except now instead of saying numbers you're actually going to pasan column names of your data frame
.
So for instance I'm going to say call equals time and RHO here is equal to smoker.
Let's go ahead and run that's see what that looks like.
OK.
Now I have an empty grid that can begin to actually map what types to this group.
For instance I'm going to go ahead and say gee got math.
S and this is going to do a this.
And let's do it on total bill.
So it's going to do to close that out and run this.
OK.
So it's actually going on here.
I am Matt being a SWAT type and separating the results based off of my column and row certain column
names and here they're labeled for us so the x axis represents total bill but there's four separate
plots and they're actually labeled for us so yes and no and smokers are the rose.
And that was specified when I said Roe equal smoker.
And then.
Or at the actual time of lunch versus dinner is specified by the column.
So the left column is lunch the right column is dinner the top row is smokers and the bottom row is
non-smokers.
And then we have distribution plots where the total bill call.
So there's essentially kind of three arguments at play here.
The rows and column names are what variables you want to separate by for your Fassett grid.
And then when you're mapping you're going to want to add in one more argument which actually want a
map for display.
If you're trying to map a plot type that needs more than one argument.
So we know this plot only needs one argument but let's say we tried to do a scatterplot by saying peel
teeth scatter.
I just said total bill here or get a type error.
But I need to do is pass an additional argument so I can go ahead and pass that in and we can say maybe
tips versus total bill.
Is then we go ahead and run that this actually just needs to be set.
So tip versus total bill.
Now we can actually see that we have tip versus total bill and we've separated both on row and column
on smokers and lunch versus dinner.
So if you're dealing with a plot type that needs more than one argument you just add that in as a second
argument in the map call.
All right.
That's actually it for the great lecture.
The reason for that is because we want to actually be using massacree grid that often throughout the
course Seaborn is basic plotting capabilities are actually quite enough for us throughout the course
.
The sort of grid functions are only here for you if you want to customize your plots even further.
And there's a link in the Jupiter notebook for this lecture with some links to the documentation and
more examples of what you can do with Fassett grid and Peregrym.
They just keep them in mind when you're looking for a little more customization some other plot types
such as regression plots actually have parameters you can pass that will automatically create a fast
grade for you.
But we're going explore that a little more when we talk about regression plots in the next lecture.
Okay.
Thanks everyone.
Feel free to post the Q Any forums if you have any questions on this topic.
I'll see at the next lecture