0
0
Matplotlibdata~10 mins

Font properties customization 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 set the font size of the title to 20.

Matplotlib
import matplotlib.pyplot as plt
plt.title('My Plot', fontsize=[1])
plt.show()
Drag options to blanks, or click blank then click option'
A10
B20
C25
D15
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of a number for fontsize.
Forgetting to pass fontsize parameter.
2fill in blank
medium

Complete the code to set the font family of the x-axis label to 'Comic Sans MS'.

Matplotlib
import matplotlib.pyplot as plt
plt.xlabel('X Axis', fontfamily=[1])
plt.show()
Drag options to blanks, or click blank then click option'
A'Comic Sans MS'
B'Times New Roman'
C'Arial'
D'Courier New'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing font family without quotes.
Choosing a font family different from the instruction.
3fill in blank
hard

Fix the error in the code to make the y-axis label bold.

Matplotlib
import matplotlib.pyplot as plt
plt.ylabel('Y Axis', fontweight=[1])
plt.show()
Drag options to blanks, or click blank then click option'
Abold
B'strong'
Cstrong
D'bold'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing fontweight without quotes causing a NameError.
Using incorrect keywords like 'strong' instead of 'bold'.
4fill in blank
hard

Fill both blanks to set the font style of the legend to italic and font size to 14.

Matplotlib
import matplotlib.pyplot as plt
plt.legend(['Data'], prop={'style': [1], 'size': [2])
plt.show()
Drag options to blanks, or click blank then click option'
A'italic'
B'bold'
C14
D12
Attempts:
3 left
💡 Hint
Common Mistakes
Using font size as a string instead of a number.
Using 'bold' instead of 'italic' for style.
5fill in blank
hard

Fill all three blanks to create a title with font family 'Verdana', font weight 'light', and font size 18.

Matplotlib
import matplotlib.pyplot as plt
plt.title('Custom Title', fontfamily=[1], fontweight=[2], fontsize=[3])
plt.show()
Drag options to blanks, or click blank then click option'
A'Verdana'
B'light'
C18
D'bold'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up fontweight values or missing quotes.
Passing font size as a string instead of a number.