Bird
0
0

Which of the following is the correct syntax to add an annotation with an arrow pointing to point (2, 4) in matplotlib?

easy📝 Syntax Q12 of 15
Matplotlib - Real-World Visualization Patterns
Which of the following is the correct syntax to add an annotation with an arrow pointing to point (2, 4) in matplotlib?
Aplt.annotate('Note', xy=(2, 4), xytext=(3, 5), arrowprops=dict(facecolor='black'))
Bplt.annotate('Note', point=(2, 4), text=(3, 5), arrow=True)
Cplt.annotation('Note', xy=(2, 4), xytext=(3, 5), arrowprops=True)
Dplt.annotate('Note', xy=(2, 4), text=(3, 5), arrowprops=dict(color='red'))
Step-by-Step Solution
Solution:
  1. Step 1: Check the function name and parameters

    The correct function is plt.annotate with parameters xy for point and xytext for text location.
  2. Step 2: Verify arrow properties

    arrowprops must be a dictionary specifying arrow style, e.g., dict(facecolor='black').
  3. Final Answer:

    plt.annotate('Note', xy=(2, 4), xytext=(3, 5), arrowprops=dict(facecolor='black')) -> Option A
  4. Quick Check:

    Correct annotate syntax uses xy, xytext, arrowprops dict [OK]
Quick Trick: Use xy and xytext with arrowprops dict for annotation [OK]
Common Mistakes:
  • Using wrong parameter names like point or text
  • Passing arrowprops as True instead of dict
  • Using plt.annotation instead of plt.annotate

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes