Bird
0
0

Identify the error in this code that tries to set figure size:

medium📝 Debug Q6 of 15
Matplotlib - Export and Publication Quality
Identify the error in this code that tries to set figure size:
import matplotlib.pyplot as plt
fig = plt.figure(figsize=[8, 4])
plt.show()
Afigsize should be a tuple, not a list
Bplt.figure does not accept figsize parameter
Cplt.show() must come before plt.figure()
DNo error, code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check figsize parameter type

    figsize accepts both tuple and list for size specification.
  2. Step 2: Verify plt.figure and plt.show order

    plt.show() is correctly called after figure creation.
  3. Final Answer:

    No error, code runs fine -> Option D
  4. Quick Check:

    figsize accepts list or tuple [OK]
Quick Trick: figsize accepts tuple or list [OK]
Common Mistakes:
  • Thinking figsize must be tuple only
  • Misordering plt.show() call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes