Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to apply the 'ggplot' style to matplotlib.
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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'seaborn' instead of 'ggplot'.
Forgetting to call plt.style.use().
✗ Incorrect
The 'ggplot' style is applied using plt.style.use('ggplot').
2fill in blank
mediumComplete the code to apply the 'seaborn' style to matplotlib.
Matplotlib
import matplotlib.pyplot as plt plt.style.use('[1]') plt.plot([1, 2, 3], [3, 2, 1]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ggplot' instead of 'seaborn'.
Not importing matplotlib.pyplot as plt.
✗ Incorrect
Use plt.style.use('seaborn') to apply the seaborn style.
3fill in blank
hardFix the error in the code to apply the dark background style correctly.
Matplotlib
import matplotlib.pyplot as plt plt.style.use('[1]') plt.plot([1, 2, 3], [6, 5, 4]) plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using camel case or missing underscore.
Using a style name that does not exist.
✗ Incorrect
The correct style name is 'dark_background' with an underscore and all lowercase.
4fill in blank
hardFill both blanks to create a plot with 'seaborn' style and a title 'My Plot'.
Matplotlib
import matplotlib.pyplot as plt plt.style.use('[1]') plt.plot([1, 2, 3], [3, 4, 5]) plt.title('[2]') plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up style names.
Forgetting to put the title string in quotes.
✗ Incorrect
Use plt.style.use('seaborn') and set the title with plt.title('My Plot').
5fill in blank
hardFill both blanks to create a plot with 'ggplot' style, plot data, and label the y-axis as 'Value'.
Matplotlib
import matplotlib.pyplot as plt plt.style.use('[1]') plt.plot([1, 2, 3], [2, 4, 6]) plt.ylabel('[2]') plt.show()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong style name.
Not setting the y-axis label correctly.
✗ Incorrect
Apply the 'ggplot' style with plt.style.use('ggplot') and label the y-axis with plt.ylabel('Value').