Bar width and positioning
📖 Scenario: You are helping a small shop owner visualize the sales of three products over a week. They want to see the sales side by side for easy comparison.
🎯 Goal: Create a bar chart using matplotlib that shows sales of three products with custom bar widths and positions so the bars do not overlap.
📋 What You'll Learn
Create a list called
days with the days: 'Mon', 'Tue', 'Wed', 'Thu', 'Fri'Create three lists called
sales_A, sales_B, and sales_C with exact sales numbersCreate a variable called
bar_width and set it to 0.2Use
matplotlib.pyplot.bar to plot three sets of bars with correct positions using bar_widthAdd a legend with labels 'Product A', 'Product B', and 'Product C'
Print the plot using
plt.show()💡 Why This Matters
🌍 Real World
Bar charts are used in business to compare sales, expenses, or other data across categories or time periods.
💼 Career
Data analysts and scientists often create bar charts to visualize and communicate data insights clearly.
Progress0 / 4 steps