Home »
Python »
Matplotlib MCQs
Why barh() function is used in plotting?
28. Why barh() function is used in plotting?
- To draw a bar graph with a specified height
- To draw a bar graph to print the highest values of a NumPy array
- To draw a horizontal bar graph
- None of the above
Answer: C) To draw a horizontal bar graph
Explanation:
The barh() function is used to draw a horizontal bar graph. The barh() function takes the same arguments as the "bar()" function. Consider the below code statement to draw a horizontal bar graph –
name = ["Alvin", "Alex"]
age = [21, 23]
plt.barh(name, age)