0
0
Matplotlibdata~10 mins

Seaborn style with 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 apply the seaborn style to Matplotlib plots.

Matplotlib
import matplotlib.pyplot as plt
plt.style.use('[1]')
plt.plot([1, 2, 3], [4, 5, 6])
plt.show()
Drag options to blanks, or click blank then click option'
Aggplot
Bclassic
Cseaborn
Dbmh
Attempts:
3 left
💡 Hint
Common Mistakes
Using a style name that is not installed or recognized.
Forgetting to import matplotlib.pyplot as plt.
2fill in blank
medium

Complete the code to create a scatter plot with seaborn style applied.

Matplotlib
import matplotlib.pyplot as plt
plt.style.use('seaborn')
x = [1, 2, 3, 4]
y = [10, 20, 25, 30]
plt.[1](x, y)
plt.show()
Drag options to blanks, or click blank then click option'
Ascatter
Bbar
Chist
Dplot
Attempts:
3 left
💡 Hint
Common Mistakes
Using plt.plot which creates a line plot instead of scatter.
Using plt.bar which creates bar charts.
3fill in blank
hard

Fix the error in the code to correctly apply seaborn style and plot a histogram.

Matplotlib
import matplotlib.pyplot as plt
plt.style.use('seaborn')
data = [1, 2, 2, 3, 3, 3, 4]
plt.hist(data, bins=[1])
plt.show()
Drag options to blanks, or click blank then click option'
A5
B'5'
C'bins=5'
Dbins
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the number of bins as a string instead of an integer.
Passing the parameter name as a string inside the function call.
4fill in blank
hard

Fill both blanks to create a line plot with seaborn style and add a grid.

Matplotlib
import matplotlib.pyplot as plt
plt.style.use('[1]')
plt.plot([1, 2, 3], [3, 2, 1])
plt.[2](True)
plt.show()
Drag options to blanks, or click blank then click option'
Aseaborn
Bclassic
Cgrid
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong style name.
Forgetting to enable the grid with plt.grid(True).
5fill in blank
hard

Fill all three blanks to create a seaborn style bar chart with labels.

Matplotlib
import matplotlib.pyplot as plt
plt.style.use('[1]')
categories = ['A', 'B', 'C']
values = [5, 7, 3]
plt.bar(categories, values)
plt.xlabel('[2]')
plt.ylabel('[3]')
plt.show()
Drag options to blanks, or click blank then click option'
Aseaborn
BCategory
CValue
Dclassic
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong style name.
Leaving axis labels empty or unclear.