Complete the code to set the font size of the title to 20.
import matplotlib.pyplot as plt plt.title('My Plot', fontsize=[1]) plt.show()
The fontsize parameter controls the size of the font. Setting it to 20 makes the title larger.
Complete the code to set the font family of the x-axis label to 'Comic Sans MS'.
import matplotlib.pyplot as plt plt.xlabel('X Axis', fontfamily=[1]) plt.show()
The fontfamily parameter sets the font style. 'Comic Sans MS' is a playful font often used for informal plots.
Fix the error in the code to make the y-axis label bold.
import matplotlib.pyplot as plt plt.ylabel('Y Axis', fontweight=[1]) plt.show()
The fontweight parameter requires a string value like 'bold' to make the font bold.
Fill both blanks to set the font style of the legend to italic and font size to 14.
import matplotlib.pyplot as plt plt.legend(['Data'], prop={'style': [1], 'size': [2]) plt.show()
The prop dictionary controls font properties of the legend. 'style' set to 'italic' makes text slanted, and 'size' sets the font size.
Fill all three blanks to create a title with font family 'Verdana', font weight 'light', and font size 18.
import matplotlib.pyplot as plt plt.title('Custom Title', fontfamily=[1], fontweight=[2], fontsize=[3]) plt.show()
Setting fontfamily to 'Verdana', fontweight to 'light', and fontsize to 18 customizes the title font as requested.