Hello everyone and welcome to the Seaborn exercises solution's lecture this lecture.
We're going to go over the solutions for the seaborne exercises.
Let's go ahead and jump to Jupiter notebook to get started.
All right here I am at the Jupiter notebook we have the data and load it up and we're going to go ahead
and jump to the first plot we want to replicate.
All right looking at this plot hopefully you can tell that this is a distribution plot and it's actually
the joint plot because you're showing two distributions on top of each other and then you could have
read this and seen that it's the fair versus the age of the data set.
Let's go ahead and show you how we can run this.
We're going to run these lines again.
So I actually import everything correctly and then I'm going to go ahead and type in my code.
So this is a joint plot's where you have the fair
and on the y axis you have age and our dataset is just the Titanic data and that will replicate that
plot for you.
Again it's just a joint plot.
All right.
Coming up next is this distribution plot.
And this is a this plots so you can just see Asinus this plot.
Titanic and then pass and the column we want and if we take a look here at the bottom this is the Fair
column.
So the distribution of the Fair column.
Let me go to put this just this line by itself as a new plots.
All right.
So this is what you get when you see just as soon as this plot something you want to do in order to
replicate this plot is remove this Cady's.
So I want to go and say easy cool false here and now we're getting a little closer.
Something else to note here is that the color is red.
So you can also specify color equals red although as I mentioned the instructions you don't have to
worry too much about the actual colors.
And then there's also less bends here in the fair.
So after experimenting with some bin's numbers you can hopefully discover that the bins are around 30
for the plot.
And so that's the actual code for the plot.
The distribution plot.
In this case this plot Titanic fair equals false and then some extra information read in bins.
If you were able to get red or the bin's argument don't worry about that.
The only thing I'm really concerned about you recognizing is that this was a plot with the Eagles false
on the Fair column.
OK moving on to the next plot.
This is clearly a box plot and it looks like the class is on the x axis and the age is on the y axis
.
Let's go ahead and check that out.
In order to do this all you have to say is as Sinistar box plot as in the class and then pass in the
age for y and then the data is equal to the Titanic data set.
We can go ahead and run that.
And one last thing which doesn't matter if you didn't get it or not but the actual color scheme is the
rainbow color scheme.
So we can also specify palettes is equal to Rainbow.
And again don't worry if we were able to get the color to match I just want you to recognize that it's
a box plot and then be able to read the X versus the Y and fill that in.
Moving on to the next one sounds a little trickier because it's the swarm plot in which you have to
do is say as soon as the swarm plot and this is actually everything the same as far as class versus
age so you can actually just come up here.
Copy all this is going and copy everything including the palette and just have this one plot.
This is the Suaram plot version of the box plot we just showed.
And this color scheme in case you're curious of what it was.
This is actually the set to color scheme but again don't worry if we're not able to get the color seemed
correct.
That doesn't really matter what I want should be able to get correct is the x y and data source for
swarm plot.
Next one that we want to check out was this bar plot.
But take careful note that it says count here.
So is actually a counterplot and you can create a counterplot just by saying S and S counterplot passing
the column you want to count.
In this case we take a look over here see sex column in our data source is the Titanic data frame and
that's the plot right there.
Color scheme is the original color scheme that we have this plot right here.
Sounds a little trickier.
Notice that we have values between negative 1 and once it goes from this cool war mapping and the other
hint here is that you can see at the very top the title is titanic dot c o r r c is clearly a correlation
plot and we want to use heape map on this.
So we're going to go ahead and do this.
We're going to say Asinus heat map and pasand Titanic dark core and we can also say sea map is equal
to cool warm.
And this is going to replicate that plot in the solutions notebook.
I also added a title on this called P.L..
The title Titanic got c o r r.
Close parentheses.
And that was actually just to give you a hint as you were looking at the figure as to what the information
actually was.
All right.
Let's go ahead and move on to the last plot which is a little tricky because this one's using Fassett
grid system is going to be done in two lines.
First off let's take a look at what we're actually doing.
It looks like the columns are sex equals male and sex equals female.
So we want to create a Fassett grid separated by the column sex organ of say data is equal to Titanic
and call is equal to sex.
And then I'm going to go out and set that equal to g as we did in the earlier examples and then I'm
going to map it looks like this is a histogram.
So there's different ways of doing this.
But the easiest way is to say peel t the highest and then the arguments actually want to do a histogram
of his age.
So you could have done that which you could have also done is to get a similar plot.
Exactly the same is just plot this sort of also shown a K the top.
OK.
I hope you found this interesting and I hope you found really the true power of seaborne to create beautiful
visualizations and just very few lines of code as long as you have your data framed set up correctly
.
OK.
Go ahead and post any questions you have to the Q&A forums and check out the Juber new book If You Want
some more reference code.
Thanks everyone and I'll see you at the next lecture