Visualization & Trending
Turning Numbers into Something the Eye Can Read
A table of numbers asks the reader to do the work. A good chart does the work for them. Visualization maps data onto position, length, and colour so patterns jump out at a glance — bar charts for comparison, line charts for time, heatmaps for density. Trending is the time-aware half of this step: it reveals growth, decline, seasonality, and turning points, usually by smoothing short-term noise into a readable longer-term signal.
Pick the chart that matches the question, then smooth the series to expose the underlying trend.
Choosing the Right Chart
- Line chart — a value over time (revenue by month). The default for trending.
- Bar chart — comparison across categories (sales by region).
- Heatmap — density or intensity across two dimensions (sales by region × month).
- Scatter plot — the relationship between two numeric variables (discount vs profit).
Trending: Smoothing the Signal
Raw monthly numbers bounce around. A rolling (moving) average averages each point with its neighbours, flattening the noise so growth, decline, and seasonality become obvious. The wider the window, the smoother — and the slower to react — the line becomes.
In Python — chart + rolling trend
Python · pandas + matplotlib
import pandas as pd
import matplotlib.pyplot as plt
# Monthly sales series
monthly = (orders
.assign(month=orders["order_date"].dt.to_period("M").dt.to_timestamp())
.groupby("month")["sales"].sum())
# 3-month rolling average smooths the noise into a trend
trend = monthly.rolling(window=3, min_periods=1).mean()
ax = monthly.plot(label="Monthly sales", alpha=0.5)
trend.plot(ax=ax, label="3-month trend", linewidth=2)
ax.set_title("Monthly sales with rolling trend")
ax.legend()
plt.tight_layout()
plt.show()
In SQL — moving average with a window function
SQL
SELECT
DATE_TRUNC('month', order_date) AS month,
SUM(sales) AS monthly_sales,
AVG(SUM(sales)) OVER (
ORDER BY DATE_TRUNC('month', order_date)
ROWS BETWEEN 2 PRECEDING AND CURRENT ROW
) AS sales_3m_avg
FROM orders
GROUP BY DATE_TRUNC('month', order_date)
ORDER BY month;
Tools Commonly Used
- Python: Matplotlib, Seaborn, Plotly; Pandas
rollingfor smoothing. - SQL: windowed
AVG() OVER (...)for moving averages. - Power BI / Tableau: line/bar visuals, trend lines, and built-in moving-average quick calcs.
Best Practices
- Match the chart to the question — don't use a pie chart where a bar chart is clearer.
- Start value axes at zero for bar charts to avoid exaggerating differences.
- Label axes and units; a chart without context is decoration, not analysis.
- Show the raw series and the smoothed trend together so readers see what was filtered out.
Example: Retail Sales Trend
For the retail dataset, this step typically yields:
- A line chart of monthly sales with a 3-month rolling average revealing a clear seasonal lift in Q4.
- A bar chart ranking categories by total sales.
- A region × month heatmap that exposes which markets drive the year-end spike.