Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Intro to Seaborn!
You have completed Intro to Seaborn!
Preview
Now that we've completed making plots to analyze our numerical values, let's move on to explore how Attribute, a categorical variable, is related to certain quantitative variables.
Challenge
- For each Attribute, what is the relationship between Attribute and:
- Attack Points?
- Defense Points?
Hint: use sns.stripplot
and sns.swarmplot
.
Solution
sns.stripplot(data=monsters, x='Attributes', y='Attack_Points')
sns.catplot(kind='strip', data=monsters, x='Attributes', y='Attack_Points', aspect=1.5)
sns.stripplot(data=monsters, x='Attack_Points', y='Attributes')
sns.swarmplot(data=monsters, x='Attack_Points', y='Attributes')
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Now that we've completed making plots
to analyze our numerical values,
0:00
let's move on to explore how attribute,
a categorical variable,
0:05
is related to certain
quantitative variables.
0:10
For each attribute, what is
the relationship between attribute and
0:14
attack points, and
attribute and defense points?
0:19
Here's a hint, use sns.stripplot and
sns.swarm plot.
0:23
We haven't used swarm plot in
our previous practices yet.
0:30
So if you need help figuring it out,
0:33
check the method signature documentation
by using the Shift Tab keyboard command.
0:35
Or reference the seaborn documentation.
0:41
A swarm plot is very
similar to a stripplot,
0:45
but it plots out individual
observations more distinctly.
0:48
Pause me and try it out.
0:52
And then I'll catch you on the other side.
0:54
How did the challenge go?
0:58
Here's how I did it.
1:00
For a stripplot, sns.stripplot
1:03
(data=monsters, x= Attribute,
1:09
and y=Attack_Points.
1:15
Whoops, I've got a value error.
1:25
It says that it could not
interpret the input Attribute.
1:27
Let's make sure I spelled that right.
1:34
So I'm gonna scroll all the way up.
1:36
And it's called Attributes not Attribute.
1:40
Just a little typo,
I can fix that by adding an s.
1:44
There we go.
1:50
So there's another way
to make these plots so
1:52
that the categorical
labels are more readable.
1:55
In this plot,
they are spaced out pretty well.
1:58
But I can switch the x and
y-axis labels around.
2:02
sns.stripplot (data = monsters and
2:08
x = Attack_Points.
2:14
And y = Attributes.
2:24
So it's up to your personal preference
of what you think is more readable.
2:34
If you like the categorical
attributes on the x-axis or
2:38
on the y-axis, it's up to you.
2:43
And I can do the same thing
with the swarm plot method.
2:47
sns.swarmplot (data=monsters,
2:51
for this one,
let's plot our attributes on the y-axis.
2:59
So for the x-axis, we'll say
Defense_Points and y= Attributes.
3:04
Nice, great job making these
categorical scatter plots.
3:19
In the next challenge, we'll talk
about categorical distribution plots.
3:24
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up