Create Small Multiples (Facet Grid) with Matplotlib
📖 Scenario: You are a data analyst at a fruit store. You have sales data for different fruits over several months. You want to compare the monthly sales of each fruit side by side to see trends easily.
🎯 Goal: Build a small multiples (facet grid) plot using matplotlib to show monthly sales for each fruit in separate subplots.
📋 What You'll Learn
Create a dictionary with fruit names as keys and lists of monthly sales as values.
Create a list of month names to use as x-axis labels.
Use a configuration variable to store the number of fruits.
Use a loop to create subplots for each fruit.
Plot monthly sales data for each fruit in its own subplot.
Add titles to each subplot with the fruit name.
Display the final figure with all subplots.
💡 Why This Matters
🌍 Real World
Small multiples help compare different groups or categories side by side, making it easier to spot patterns or differences in data over time or conditions.
💼 Career
Data analysts and scientists often use facet grids to visualize segmented data clearly, which helps in reporting and decision-making.
Progress0 / 4 steps