← Back to Descriptive Analytics

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.

From rows, to a chart, to a trend Aggregated data sales by month Chart bar · line · heatmap Trend smoothed · seasonal

Pick the chart that matches the question, then smooth the series to expose the underlying trend.

Choosing the Right Chart

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

Best Practices

Example: Retail Sales Trend

For the retail dataset, this step typically yields:

← Back to Descriptive Analytics