Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 38 ยท Projects and Practice

Project: A Sales Dashboard with Seaborn

Build a one-page sales dashboard: tidy the data with pandas, then combine a trend line, category bars, a heatmap and a distribution in one seaborn and Matplotlib figure.

A dashboard is several charts arranged so one glance answers a set of questions. In notebooks and reports you can build one with a single Matplotlib figure and seaborn's axes-level functions, which draw on any Axes you give them. This project builds a four-panel sales dashboard from synthetic data: a monthly trend, revenue by category, a weekday-by-hour heatmap and the distribution of order values.

The skills are all things you have met: date handling, barplot, heatmap, histplot, themes and layout. The new part is combining them with a layout, a consistent palette and good titles, so the dashboard reads as one design.

Plan the dashboard first

Before any code, decide the questions and the chart for each:

Dashboard plan

Is revenue growing? Monthly line with a 3-month average.
What sells? Horizontal bars by category.
When do people buy? Heatmap of weekday by hour.
How big are orders? Histogram with median marked.

One question per panel. Titles state the finding.

1 / 2

Step 1: the data

Generate 6,000 orders across 2025 with a growth trend, a December bump, category differences and a lunchtime and weekend pattern.

Python Create and aggregate the order data

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check the numbers before you draw: counts, totals and the ordering of categories. Dashboards that "look right" but rest on a wrong aggregation are the worst kind.

Step 2: the four-panel figure

Use plt.subplots with a 2 by 2 grid, or GridSpec for unequal panels. Pass each Axes to the seaborn function with ax=. This is the mirror image of the figure-level functions: you control the layout, seaborn draws.

Python The dashboard

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

What to notice in the code:

  • One theme for all panels. set_theme once, so fonts, grid and palette agree.
  • Colour has a job. Grey for the raw line, strong blue for the smoothed one; the heatmap uses a sequential map because counts go from low to high.
  • Titles state findings ("Revenue climbs through the year") rather than naming the chart type ("Line plot").
  • Rolling with min_periods=1 avoids a gap at the start.
  • observed=False silences a pandas warning about categorical weekday groups and keeps every weekday.
  • tight_layout(rect=...) leaves headroom for the figure title.

Step 3: improve and save

Review the dashboard with fresh eyes:

  1. Can each panel be understood without reading the code? Add a unit to axis labels ("Revenue ($)").
  2. Is anything redundant? The bar chart's colours repeat the labels; drop the colour variation (color="#4c78a8") to focus attention.
  3. Is the story in the right order? Put the question that matters most top left.
  4. Does it survive greyscale and colour-blind viewing? Sequential maps do; avoid red-green pairs.

To save for a report, use fig.savefig("dashboard.png", dpi=200, bbox_inches="tight"); see saving figures. On the site the picture appears directly under the code.

Extensions

  • Add a fifth panel: revenue by category over time using lineplot(hue="category").
  • Add confidence bands by plotting the raw orders with errorbar=("ci", 95) on a weekly resample (time series).
  • Switch to a GridSpec where the trend spans the full top row.
  • Wrap the code in a function make_dashboard(df, title) so any dataset with the same columns produces a dashboard.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why use axes-level functions with ax= for a dashboard?

    Axes-level functions draw on any Axes, so you can combine different chart types in one figure.
  2. 2. Which is a better panel title?

    A title that states the finding tells the reader what to look for.
  3. 3. Why is a sequential colormap right for the weekday-by-hour heatmap?

    Counts have no meaningful centre, so a diverging map would invent one.
  4. 4. What does rect=(0, 0, 1, 0.96) in tight_layout do?

    rect restricts the area the subplots may occupy, in figure fractions.

Summary

  • Plan one question per panel before drawing.
  • Build the layout with plt.subplots/GridSpec and fill panels with axes-level seaborn calls.
  • Share one theme and palette; use colour for meaning; write titles as findings.
  • Verify aggregations with printed tables before trusting the picture.

Next: Project: An A/B Test Report