Complete the code to set the font size of the title to 16.
import matplotlib.pyplot as plt plt.title('Sample Plot', fontsize=[1]) plt.show()
The fontsize parameter controls the size of the title text. Setting it to 16 makes the title clearly visible.
Complete the code to set the font size of x-axis labels to 14.
import matplotlib.pyplot as plt plt.xlabel('X Axis', fontsize=[1]) plt.show()
Setting fontsize=14 makes the x-axis label easy to read without being too large.
Fix the error in the code to set the font size of y-axis tick labels to 12.
import matplotlib.pyplot as plt ax = plt.gca() plt.plot([1, 2, 3], [4, 5, 6]) plt.setp(ax.get_yticklabels(), fontsize=[1]) plt.show()
The fontsize parameter must be an integer, not a string. Passing 12 sets the tick label font size correctly.
Fill both blanks to create a dictionary setting font sizes for title and labels.
font_sizes = {'title': [1], 'label': [2]Common font size guidelines use 16 for titles and 14 for labels to keep text balanced and readable.
Fill all three blanks to create a font size dictionary and apply it to a plot.
font_sizes = {'title': [1], 'xlabel': [2], 'ylabel': [3]
import matplotlib.pyplot as plt
plt.title('My Plot', fontsize=font_sizes['title'])
plt.xlabel('X Axis', fontsize=font_sizes['xlabel'])
plt.ylabel('Y Axis', fontsize=font_sizes['ylabel'])
plt.show()Using 16 for title, 14 for xlabel, and 12 for ylabel follows common font size guidelines for clear and balanced plots.