BaşlayınÜcretsiz Başlayın

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.

Bu egzersiz

Introduction to Data Visualization with Seaborn

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Set the color palette to "Blues".
  • Add subgroups to color the box plots based on "Interested in Pets".
  • Set the title of the FacetGrid object g to "Age of Those Interested in Pets vs. Not".
  • Make the plot display using a Matplotlib function.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# 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.____
Kodu Düzenle ve Çalıştır