Bird
0
0

What will be the output of this code snippet?

medium📝 Predict Output Q5 of 15
Matplotlib - Export and Publication Quality
What will be the output of this code snippet?
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(5, 5))
print(ax.figure.get_size_inches())
A[5. 5.]
B[1. 1.]
C[10. 10.]
D[0.5 0.5]
Step-by-Step Solution
Solution:
  1. Step 1: Understand subplots figsize

    figsize=(5, 5) sets figure width and height to 5 inches each.
  2. Step 2: Access figure size from axis

    ax.figure.get_size_inches() returns the figure size as an array.
  3. Final Answer:

    [5. 5.] -> Option A
  4. Quick Check:

    Subplots figsize output = [5. 5.] [OK]
Quick Trick: Use ax.figure.get_size_inches() to get figure size [OK]
Common Mistakes:
  • Confusing axis size with figure size
  • Expecting tuple instead of array

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes