CBSE Class 12 Informatics Practices Question 105 of 147

Plotting with Pyplot — Question 5

Back to all questions
5
Question

Question 5

Compare bar() and barh() functions.

Answer
bar() functionbarh() function
This function is used to create vertical bar charts.This function is used to create horizontal bar charts.
In a vertical bar chart, the bars are plotted along the vertical axis (y-axis) with their lengths representing the values being plotted.In a horizontal bar chart, the bars are plotted along the horizontal axis (x-axis) with their lengths representing the values being plotted.
The first sequence given in the bar() forms the x-axis and the second sequence values are plotted on y-axis.The first sequence given in the barh() forms the y-axis and the second sequence values are plotted on x-axis.