Startup Performance Dashboard
Project Overview & Use Case
While Pandas and NumPy are excellent for calculating numbers, humans understand data best when it is visual. Matplotlib is the foundational plotting library in Python used to create static, animated, and interactive visualizations.
The Use Case: Imagine you are a data analyst at a rapidly growing tech startup. The CEO needs a quick, professional visual dashboard to present to investors at the mid-year meeting. You need to show user growth, monthly revenue, and how different products contribute to total sales.
The Output: This script generates a single, professional window containing three different types of charts (a line graph, a bar chart, and a pie chart) neatly arranged side-by-side using Matplotlib’s powerful subplots feature.
System Workflow (How It Works)
Data Definition: The script defines static lists containing mock data for the first six months of the year (months, active users, revenue, and product categories).
Figure & Axes Creation: It creates a main “canvas” (the Figure) and divides it into a 1x3 grid (three smaller canvases called Axes) so all charts display in the same window.
Plotting Chart 1 (Line Graph): It plots the active user growth over time, adding data markers (dots) and a background grid for readability.
Plotting Chart 2 (Bar Chart): It plots the monthly revenue using vertical bars, customizing the color to green.
Plotting Chart 3 (Pie Chart): It displays the market share of three different products, automatically calculating the percentages.
Rendering: It adjusts the layout so nothing overlaps and displays the final interactive dashboard on your screen.
Source Code
import matplotlib.pyplot as plt
def generate_dashboard():
"""
Creates a multi-chart dashboard to visualize startup performance data.
"""
print("📊 Generating Startup Performance Dashboard...")
# --- 1. The Data ---
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
# Data for Line Chart
active_users = [1200, 1500, 2100, 2900, 4200, 5500]
# Data for Bar Chart
revenue = [15000, 18000, 24000, 31000, 45000, 60000]
# Data for Pie Chart
products = ['Mobile App', 'Web Platform', 'API Services']
market_share = [55, 30, 15] # Percentages
# --- 2. Setup the Canvas (Figure and Axes) ---
# Create 1 row, 3 columns. figsize defines the window size in inches (width, height)
fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(15, 5))
# Add a main title for the entire dashboard
fig.suptitle('🚀 Tech Startup Mid-Year Performance Report', fontsize=16, fontweight='bold')
# --- 3. Chart 1: Line Graph (Active Users) ---
# axes[0] refers to the first (left) chart
axes[0].plot(months, active_users, color='blue', marker='o', linestyle='-', linewidth=2)
axes[0].set_title('Active User Growth')
axes[0].set_xlabel('Month')
axes[0].set_ylabel('Total Users')
axes[0].grid(True, linestyle='--', alpha=0.6) # Add a faint grid
# --- 4. Chart 2: Bar Chart (Monthly Revenue) ---
# axes[1] refers to the second (middle) chart
axes[1].bar(months, revenue, color='green', edgecolor='black')
axes[1].set_title('Monthly Revenue')
axes[1].set_xlabel('Month')
axes[1].set_ylabel('Revenue ($ USD)')
# --- 5. Chart 3: Pie Chart (Product Share) ---
# axes[2] refers to the third (right) chart
colors = ['#ff9999', '#66b3ff', '#99ff99'] # Custom hex colors
# explode pulls the first slice ('Mobile App') out slightly for emphasis
axes[2].pie(market_share, labels=products, colors=colors,
autopct='%1.1f%%', startangle=90, explode=(0.1, 0, 0))
axes[2].set_title('Revenue by Product')
# --- 6. Final Adjustments and Rendering ---
# tight_layout() automatically adjusts spacing so titles and labels don't overlap
plt.tight_layout()
print("✅ Dashboard generated successfully! Close the pop-up window to exit the script.")
# Display the plot to the user
plt.show()
if __name__ == "__main__":
generate_dashboard()
Code Explanation (Matplotlib Concepts)
plt.subplots(1, 3): This is the modern, Object-Oriented way to use Matplotlib. It returns two things: fig (the entire window/canvas) and axes (a list containing the three individual chart areas). By indexing axes (e.g., axes[0], axes[1]), we can command exactly which chart we want to draw on.
.plot(): The standard function for drawing line graphs. The marker=‘o’ argument places a distinct dot at every data point, making it easier to read exactly where the month aligns with the user count.
.bar(): The function for drawing bar charts. We passed edgecolor=‘black’ to give the green bars a crisp border, making them stand out against the white background.
.pie(): The function for pie charts. The autopct=‘%1.1f%%’ argument tells Matplotlib to automatically calculate the percentages and format them to one decimal place inside the pie slices.
plt.tight_layout(): A critical function when using subplots. Without this, the labels of one chart might bleed into the title of the chart next to it. This function calculates the perfect padding between elements.
plt.show(): Matplotlib builds the charts in the background. Nothing actually appears on your screen until you call this final function.
Execution Guide
Install Matplotlib: Open your terminal or command prompt and run: pip install matplotlib
Save the file: Create a new Python file named startup_dashboard.py and paste the provided code.
Run the script: Navigate to the folder in your terminal and execute: python startup_dashboard.py
Review Output: A new interactive window will open on your computer displaying all three charts. You can use the buttons at the bottom of the window to zoom in, pan around, or even save the dashboard as a .png image!