Bird
0
0

What is wrong with this code?

medium📝 Debug Q7 of 15
Matplotlib - Real-World Visualization Patterns
What is wrong with this code?
import matplotlib.pyplot as plt
plt.plot([1,2,3], [3,2,1])
plt.annotate('Low', xy=(2,2), xytext=(3,1), arrowprops='->')
plt.show()
Axy and xytext coordinates are reversed
Barrowprops should be a dictionary, not a string
CMissing plt.show() call
DNo error, code runs correctly
Step-by-Step Solution
Solution:
  1. Step 1: Check arrowprops parameter

    arrowprops must be a dictionary specifying arrow style, not a string.
  2. Step 2: Identify error cause

    Passing a string causes a TypeError or unexpected behavior.
  3. Final Answer:

    arrowprops should be a dictionary, not a string -> Option B
  4. Quick Check:

    arrowprops must be dict = arrowprops should be a dictionary, not a string [OK]
Quick Trick: arrowprops needs dict like dict(arrowstyle='->') [OK]
Common Mistakes:
  • Passing arrowprops as string
  • Swapping xy and xytext
  • Forgetting plt.show()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes