0
0
Matplotlibdata~10 mins

KDE overlay concept in Matplotlib - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the seaborn library as sns.

Matplotlib
import [1] as sns
Drag options to blanks, or click blank then click option'
Amatplotlib
Bseaborn
Cnumpy
Dpandas
Attempts:
3 left
💡 Hint
Common Mistakes
Importing matplotlib instead of seaborn.
Using wrong alias like 'sb' instead of 'sns'.
2fill in blank
medium

Complete the code to create a KDE plot of data1 with shading.

Matplotlib
sns.kdeplot([1], shade=True)
Drag options to blanks, or click blank then click option'
Adata2
Bdata
Cdata1
Dvalues
Attempts:
3 left
💡 Hint
Common Mistakes
Using data2 instead of data1.
Passing a wrong variable name.
3fill in blank
hard

Fix the error in the code to overlay KDE plots of data1 and data2 on the same axes.

Matplotlib
sns.kdeplot(data1, shade=True)
sns.kdeplot([1], shade=True)
Drag options to blanks, or click blank then click option'
Avalues
Bdata1
Cdata
Ddata2
Attempts:
3 left
💡 Hint
Common Mistakes
Plotting data1 twice.
Using a variable not defined.
4fill in blank
hard

Fill both blanks to create KDE plots of data1 and data2 with different colors.

Matplotlib
sns.kdeplot([1], shade=True, color='blue')
sns.kdeplot([2], shade=True, color='red')
Drag options to blanks, or click blank then click option'
Adata1
Bdata2
Cvalues
Ddataset
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping data1 and data2.
Using the same color for both plots.
5fill in blank
hard

Fill all three blanks to create KDE plots of data1 and data2 with labels and a legend.

Matplotlib
sns.kdeplot([1], shade=True, label=[2], color=[3])
sns.kdeplot(data2, shade=True, label='Data 2', color='red')
plt.legend()
Drag options to blanks, or click blank then click option'
Adata1
B'Data 1'
C'blue'
D'green'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to add labels.
Not calling plt.legend() to show the legend.