Something went wrong!
Hang in there while we get back on track
Comparing Product Line Performance
Demonstrates grouped bar chart recommendation for comparing multiple categories across time periods, with professional Python code and actionable business insights.
Input
What you provide to the skill
I have sales data for three product lines and need to compare their quarterly performance
Output
What the skill generates for you
VISUALIZATION RECOMMENDATION
📊 Your Data: 3 product lines × 4 quarters (12 data points total)
🎯 Your Goal: Compare quarterly performance across product lines
RECOMMENDED: Grouped Bar Chart
✅ Why this works:
- Perfect for comparing multiple categories (products) across time periods (quarters)
- Side-by-side bars make direct comparisons immediate and obvious
- Quarterly progression visible within each product line
- Clear visual hierarchy shows both individual quarter performance and trends
- Easy to spot winners, losers, and growth patterns at a glance
❌ NOT Recommended:
- Line chart: Could work but bars better emphasize discrete quarterly comparisons
- Stacked bar chart: Would obscure individual product performance (hard to compare middle/bottom segments)
- Multiple pie charts: Terrible for trend analysis and comparisons
- Heat map: Overkill for this data size, less intuitive for stakeholders
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
data = pd.read_csv('sales_data.csv')
# Create grouped bar chart
fig, ax = plt.subplots(figsize=(12, 7))
quarters = ['Q1', 'Q2', 'Q3', 'Q4']
product_lines = ['Product_A', 'Product_B', 'Product_C']
colors = ['#2E86AB', '#A23B72', '#F18F01'] # Colorblind-friendly palette
x = np.arange(len(quarters))
width = 0.25
for i, product in enumerate(product_lines):
product_data = data[data['Product_Line'] == product].sort_values('Quarter')
sales = product_data['Sales'].values
offset = (i - 1) * width
bars = ax.bar(x + offset, sales, width, label=product.replace('_', ' '), color=colors[i], alpha=0.85)
# Add value labels on bars
for j, (bar, value) in enumerate(zip(bars, sales)):
height = bar.get_height()
ax.text(bar.get_x() + bar.get_width()/2., height,
f'${value/1000:.0f}K',
ha='center', va='bottom', fontsize=9, fontweight='bold')
ax.set_xlabel('Quarter', fontsize=13, fontweight='bold')
ax.set_ylabel('Sales ($)', fontsize=13, fontweight='bold')
ax.set_title('Quarterly Sales Performance by Product Line', fontsize=15, fontweight='bold', pad=20)
ax.set_xticks(x)
ax.set_xticklabels(quarters)
ax.legend(loc='upper left', fontsize=11)
ax.yaxis.set_major_formatter(plt.FuncFormatter(lambda x, p: f'${int(x/1000)}K'))
ax.grid(axis='y', alpha=0.3, linestyle='--')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.tight_layout()
plt.savefig('quarterly_sales_comparison.png', dpi=300, bbox_inches='tight')
plt.show()
KEY INSIGHTS
Performance Summary
Product A - Market Leader
- Total Sales: $1,144,000 (45% of total revenue)
- Q1→Q4 Growth: +21.6%
- Peak Quarter: Q3 ($312,000)
- Strong upward trajectory with slight Q4 softening
Product B - Steady Performer
- Total Sales: $813,000 (32% of total revenue)
- Q1→Q4 Growth: +19.3%
- Peak Quarter: Q4 ($223,000)
- Consistent growth every quarter, accelerating into Q4
Product C - Declining
- Total Sales: $585,000 (23% of total revenue)
- Q1→Q4 Growth: -4.5% (ONLY product line with negative growth)
- Peak Quarter: Q1 ($156,000)
- Concerning downward trend throughout the year
Critical Observations
✓ Products A & B show healthy growth (both ~20% Q1→Q4)
✓ Product A dominates with nearly half of total revenue
⚠ Product C is struggling - consecutive quarterly declines after Q1
⚠ Product A’s Q3→Q4 dip (-4.5%) warrants investigation
Recommended Actions
- Investigate Product C decline - Is this market shift, pricing issue, or competitive pressure?
- Analyze Product A’s Q4 softening - Seasonal or early warning sign?
- Study Product B’s success - What’s driving its acceleration?
- Consider resource reallocation - Product C’s trend suggests strategic review needed
About This Skill
Analyzes your data and goals to recommend the optimal chart type, explains why it works, and generates professional Python visualizations ready for presentations.
View Skill DetailsMore Examples
Multi-Metric Marketing Analysis
Shows bubble chart recommendation for correlating three metrics (CAC, retention, LTV) across categories, with investor-ready analysis and quadrant insights.
Sparse Temporal Data Patterns
Demonstrates stem plot (lollipop chart) for visualizing sparse event data where most days have zero occurrences, with threshold highlighting and pattern analysis.