Individual subplot customization
📖 Scenario: You are analyzing sales data for two different products over four quarters. You want to visualize the sales trends side by side using two subplots. Each subplot should have its own title and y-axis label to clearly show which product's sales are being displayed.
🎯 Goal: Create a figure with two subplots side by side. Plot the sales data for Product A in the first subplot and Product B in the second subplot. Customize each subplot with its own title and y-axis label.
📋 What You'll Learn
Create a list called
quarters with values [1, 2, 3, 4].Create two lists called
sales_a and sales_b with sales data for Product A and Product B respectively.Create a figure with two subplots side by side using
plt.subplots() with 1 row and 2 columns.Plot
sales_a against quarters in the first subplot.Plot
sales_b against quarters in the second subplot.Set the title of the first subplot to
'Product A Sales' and the y-axis label to 'Sales (units)'.Set the title of the second subplot to
'Product B Sales' and the y-axis label to 'Sales (units)'.Display the plot using
plt.show().💡 Why This Matters
🌍 Real World
Visualizing multiple related datasets side by side helps compare trends easily, such as sales of different products over time.
💼 Career
Data scientists and analysts often create customized subplots to present clear and informative visual reports to stakeholders.
Progress0 / 4 steps