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

Added 24 Feb 2024

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

  1. To create a line plot
  2. To create a scatter plot
  3. To create a bar plot Correct answer
  4. To create a histogram plot

Correct answer

C. To create a bar plot

15 views

MCQSEXAM

Explanation

plt.bar() creates a bar plot with vertical bars, used for comparing categories: plt.bar(categories, values).

plt.barh() draws horizontal bars. A histogram (plt.hist()) is different — it shows the distribution of one numeric variable.

Practise more Data Science MCQs with answers and explanations on MCQsExam.com.

Doubts & discussion

Not sure why the answer is C? 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