Complete the code to import the matplotlib library.
import [1] as plt
We import matplotlib.pyplot as plt to create plots.
Complete the code to create a list of categories for the x-axis.
categories = ['A', 'B', 'C', [1]]
Categories should be strings representing groups, so 'D' is correct.
Fix the error in the code to set the width of each bar.
bar_width = [1]The bar width should be a float less than 1 to avoid overlap.
Fill both blanks to correctly calculate the x positions for the second group of bars.
x2 = [x + [1] for x in x1] plt.bar(x2, group2, width=[2], label='Group 2')
We shift the second group's bars by bar_width to place them side by side and use the same width.
Fill all three blanks to create a grouped bar chart with labels and legend.
plt.bar(x1, [1], width=[2], label='Group 1') plt.bar(x2, [3], width=bar_width, label='Group 2') plt.legend()
We plot group1 and group2 data with the same bar_width and add a legend to distinguish groups.
