1. Home
  2. Data Science
  3. Matplotlib
  4. What is the purpose of the plt.tight_layout() function in…

Added 24 Feb 2024

What is the purpose of the plt.tight_layout() function in Matplotlib?

  1. To adjust the subplot spacing automatically Correct answer
  2. To create a tight plot
  3. To set the plot legend
  4. To set the plot title

Correct answer

A. To adjust the subplot spacing automatically

13 views

MCQSEXAM

Explanation

plt.tight_layout() automatically adjusts subplot spacing so that titles, axis labels and tick labels do not overlap or get cut off.

Call it after creating all the subplots and before savefig() or show().

For more solved questions like this one, see Data Science MCQs on MCQsExam.com.

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Matplotlib MCQs

Practise all Matplotlib MCQs

Similar MCQs