0
0
Matplotlibdata~5 mins

Horizontal bar chart with plt.barh in Matplotlib - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What function in matplotlib is used to create a horizontal bar chart?
The function plt.barh() is used to create horizontal bar charts in matplotlib.
Click to reveal answer
beginner
In a horizontal bar chart, which axis represents the categories and which axis represents the values?
In a horizontal bar chart, the y-axis represents the categories, and the x-axis represents the values.
Click to reveal answer
beginner
How do you add labels to the bars in a horizontal bar chart using matplotlib?
You can add labels by using plt.xlabel() for the x-axis, plt.ylabel() for the y-axis, and plt.title() for the chart title.
Click to reveal answer
intermediate
What parameter in plt.barh() controls the height of the bars?
The height parameter controls the thickness (height) of the horizontal bars in plt.barh().
Click to reveal answer
beginner
How can you change the color of the bars in a horizontal bar chart?
You can change the bar colors by passing the color parameter to plt.barh(), for example, color='skyblue'.
Click to reveal answer
Which matplotlib function creates a horizontal bar chart?
Aplt.barh()
Bplt.bar()
Cplt.plot()
Dplt.scatter()
In a horizontal bar chart, what does the y-axis represent?
AValues
BCategories
CTime
DFrequency
How do you set the thickness of bars in plt.barh()?
Alength
Bwidth
Csize
Dheight
Which parameter changes the color of bars in plt.barh()?
Afill
Bstyle
Ccolor
Dshade
What does plt.xlabel() do in a horizontal bar chart?
ASets the label for the x-axis
BSets the chart title
CSets the label for the y-axis
DSets the legend text
Explain how to create a simple horizontal bar chart using matplotlib's plt.barh function.
Think about what data goes on each axis and how to label the chart.
You got /4 concepts.
    Describe how to customize the appearance of a horizontal bar chart, including bar thickness and color.
    Focus on parameters inside plt.barh and labeling functions.
    You got /3 concepts.