Bird
0
0

Which of the following is the correct syntax to create a figure with 6 inches width, 4 inches height, and 150 DPI in matplotlib?

easy📝 Syntax Q3 of 15
Matplotlib - Export and Publication Quality
Which of the following is the correct syntax to create a figure with 6 inches width, 4 inches height, and 150 DPI in matplotlib?
Aplt.figure(dpi=150, size=(6,4))
Bplt.figure(size=(6,4), dpi=150)
Cplt.figure(figsize=[6,4], resolution=150)
Dplt.figure(figsize=(6,4), dpi=150)
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct parameter names

    The correct parameters are figsize for size and dpi for resolution.
  2. Step 2: Check syntax format

    figsize expects a tuple, so (6,4) is correct. dpi is a keyword argument.
  3. Final Answer:

    plt.figure(figsize=(6,4), dpi=150) -> Option D
  4. Quick Check:

    Correct syntax uses figsize and dpi keywords [OK]
Quick Trick: Use figsize=(width,height), dpi=number in plt.figure() [OK]
Common Mistakes:
  • Using size instead of figsize
  • Using resolution instead of dpi
  • Passing list instead of tuple

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Matplotlib Quizzes