Bird
0
0

What will this code display?

medium📝 Predict Output Q5 of 15
Matplotlib - Real-World Visualization Patterns
What will this code display?
import matplotlib.pyplot as plt
x = [0, 1, 2, 3]
y = [1, 3, 2, 4]
plt.plot(x, y)
plt.fill_between(x, y, color='yellow', alpha=0.3)
plt.annotate('Peak', xy=(3,4), xytext=(2,5), arrowprops=dict(arrowstyle='->'))
plt.show()
ARuntime error due to invalid arrowprops
BA line plot with a yellow shaded area under the curve and an arrow annotation labeled 'Peak'
CA line plot with shaded area but annotation text only, no arrow
DA line plot with no shading and no annotation
Step-by-Step Solution
Solution:
  1. Step 1: Understand fill_between effect

    fill_between shades the area under the curve with yellow color and 30% transparency.
  2. Step 2: Analyze annotate parameters

    The annotation 'Peak' is placed at (2,5) with an arrow pointing to (3,4) using arrowstyle '->', which is valid.
  3. Final Answer:

    A line plot with a yellow shaded area under the curve and an arrow annotation labeled 'Peak' -> Option B
  4. Quick Check:

    fill_between + annotate arrow = A line plot with a yellow shaded area under the curve and an arrow annotation labeled 'Peak' [OK]
Quick Trick: fill_between shades; annotate with arrowstyle draws arrows [OK]
Common Mistakes:
  • Expecting no shading without explicit show
  • Thinking arrowstyle '->' is invalid
  • Confusing annotation text position

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes