0
0
Matplotlibdata~10 mins

Combining Seaborn and 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 seaborn with its common alias.

Matplotlib
import [1] as sns
Drag options to blanks, or click blank then click option'
Aplt
Bsns
Cmatplotlib
Dseaborn
Attempts:
3 left
💡 Hint
Common Mistakes
Using the alias name instead of the package name in the import.
Confusing matplotlib alias with seaborn.
2fill in blank
medium

Complete the code to create a matplotlib figure and axis.

Matplotlib
fig, [1] = plt.subplots()
Drag options to blanks, or click blank then click option'
Aaxes
Bax
Cplot
Dfigure
Attempts:
3 left
💡 Hint
Common Mistakes
Using figure or axes instead of ax.
Using plot which is a function, not a variable.
3fill in blank
hard

Fix the error in the code to plot a seaborn scatterplot on the matplotlib axis.

Matplotlib
sns.scatterplot(data=df, x='total_bill', y='tip', ax=[1])
Drag options to blanks, or click blank then click option'
Aax
Bplt
Cfigure
Daxes
Attempts:
3 left
💡 Hint
Common Mistakes
Passing plt or figure instead of the axis.
Not passing the axis at all.
4fill in blank
hard

Fill both blanks to set the title and label the x-axis using matplotlib on the axis object.

Matplotlib
[1].set_title('Total Bill vs Tip')
[2].set_xlabel('Total Bill ($)')
Drag options to blanks, or click blank then click option'
Aax
Bplt
Cfigure
Ddf
Attempts:
3 left
💡 Hint
Common Mistakes
Using plt instead of ax.
Using the dataframe variable df.
5fill in blank
hard

Fill all three blanks to create a seaborn histogram on a matplotlib axis, set the title, and show the plot.

Matplotlib
fig, [1] = plt.subplots()
sns.histplot(data=df, x='total_bill', ax=[2])
[3].set_title('Histogram of Total Bill')
plt.show()
Drag options to blanks, or click blank then click option'
Aax
Dfigure
Attempts:
3 left
💡 Hint
Common Mistakes
Using figure instead of ax for the axis.
Not passing the axis to seaborn.