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?
✗ Incorrect
plt.barh() creates horizontal bar charts, while plt.bar() creates vertical bar charts.
In a horizontal bar chart, what does the y-axis represent?
✗ Incorrect
The y-axis shows the categories in a horizontal bar chart.
How do you set the thickness of bars in
plt.barh()?✗ Incorrect
The height parameter controls the thickness of horizontal bars.
Which parameter changes the color of bars in
plt.barh()?✗ Incorrect
Use the color parameter to set bar colors.
What does
plt.xlabel() do in a horizontal bar chart?✗ Incorrect
plt.xlabel() sets the label for the x-axis, which shows values in a horizontal bar chart.
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.