Box plot with subgroups
In this exercise, we'll look at the dataset containing responses from a survey given to young people. One of the questions asked of the young people was: "Are you interested in having pets?" Let's explore whether the distribution of ages of those answering "yes" tends to be higher or lower than those answering "no", controlling for gender.
Deze oefening maakt deel uit van de cursus
Introduction to Data Visualization with Seaborn
Oefeninstructies
- Set the color palette to
"Blues". - Add subgroups to color the box plots based on
"Interested in Pets". - Set the title of the
FacetGridobjectgto"Age of Those Interested in Pets vs. Not". - Make the plot display using a Matplotlib function.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Set palette to "Blues"
____
# Adjust to add subgroups based on "Interested in Pets"
g = sns.catplot(x="Gender",
y="Age", data=survey_data,
kind="box", hue=____)
# Set title to "Age of Those Interested in Pets vs. Not"
____
# Show plot
plt.____