Prepare Data for a Multi-Series Chart
Intermediate · Write the code · from Matplotlib: Create Line, Bar, Scatter, and Pie Charts
From the lesson: Matplotlib: Create Line, Bar, Scatter, and Pie Charts
Imagine you have a spreadsheet with 10,000 rows of sales data. You could stare at those numbers for hours, or you could turn them into a chart and spot the trend in three seconds. That's the power of data visualization.
Read the lessonYou have quarterly revenue data for three products. Create a grouped bar chart by computing the x-positions for each group. Given quarters (4 items) and bar width 0.25, calculate x positions for three product groups so bars sit side by side. Print the x positions for each product as lists (use .tolist() to convert numpy arrays). Product A should be at positions [0, 1, 2, 3], Product B at [0.25, 1.25, 2.25, 3.25], and Product C at [0.5, 1.5, 2.5, 3.5].
More Matplotlib exercises
- Build a Temperature Line ChartIntermediate
- Build a Fruit Sales Bar ChartIntermediate
- Create a Height vs Weight Scatter PlotIntermediate
- Predict the Figure PropertiesIntermediate
- Fix the Broken LegendIntermediate
All Python exercises · 50 practice problems · Data Science & Machine Learning quiz