Recall & Review
beginner
What is a bar chart used for in data analysis?
A bar chart is used to show and compare the sizes or counts of different categories using rectangular bars. Each bar's length or height represents the value of that category.
Click to reveal answer
beginner
How do you create a simple vertical bar chart using Python's matplotlib?
Use plt.bar() with a list of categories for the x-axis and their values for the y-axis. For example:<br><pre>import matplotlib.pyplot as plt
categories = ['A', 'B', 'C']
values = [5, 7, 3]
plt.bar(categories, values)
plt.show()</pre>Click to reveal answer
beginner
What is the difference between vertical and horizontal bar charts?
Vertical bar charts have bars going up and down, showing categories on the x-axis and values on the y-axis. Horizontal bar charts have bars going left to right, showing categories on the y-axis and values on the x-axis.
Click to reveal answer
intermediate
Why might you use a horizontal bar chart instead of a vertical one?
Horizontal bar charts are useful when category names are long or when you want to compare many categories clearly because the labels are easier to read on the y-axis.
Click to reveal answer
beginner
How can you add labels and a title to a bar chart in matplotlib?
Use plt.xlabel() and plt.ylabel() to add axis labels, and plt.title() to add a chart title. For example:<br>
plt.bar(categories, values)
plt.xlabel('Categories')
plt.ylabel('Values')
plt.title('Sample Bar Chart')
plt.show()Click to reveal answer
Which matplotlib function creates a vertical bar chart?
✗ Incorrect
plt.bar() creates vertical bar charts by default.
In a horizontal bar chart, which axis shows the categories?
✗ Incorrect
In horizontal bar charts, categories are shown on the y-axis.
What does the length of a bar represent in a bar chart?
✗ Incorrect
The bar length shows the value or count for that category.
Which of these is NOT a good reason to use a horizontal bar chart?
✗ Incorrect
Time series data is better shown with line charts, not bar charts.
How do you add a title to a matplotlib bar chart?
✗ Incorrect
Use plt.title() to add a title to the chart.
Explain how to create a basic vertical bar chart in Python using matplotlib.
Think about what lists you need and the function to draw bars.
You got /5 concepts.
Describe when and why you would choose a horizontal bar chart over a vertical one.
Consider the axis where category names appear.
You got /4 concepts.