Bird
0
0

What is wrong with this code to add a title with font size 20?

medium📝 Debug Q7 of 15
Matplotlib - Seaborn Integration
What is wrong with this code to add a title with font size 20?
import matplotlib.pyplot as plt
plt.plot([1,2,3], [4,5,6])
plt.title('My Plot', fontsize=20)
plt.show()
Aplt.title() cannot set font size
Bfontsize should be font_size
CThere is no error; the code works correctly
Dplt.show() is missing parentheses
Step-by-Step Solution
Solution:
  1. Step 1: Check plt.title() parameters

    The fontsize parameter is valid to set title font size in matplotlib.
  2. Step 2: Verify code correctness

    All syntax is correct, including plt.show() with parentheses.
  3. Final Answer:

    There is no error; the code works correctly -> Option C
  4. Quick Check:

    Correct title syntax = no error [OK]
Quick Trick: Use fontsize parameter to set title size [OK]
Common Mistakes:
  • Using wrong parameter name
  • Thinking plt.title() can't set font size
  • Forgetting plt.show() parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes