Key Takeaways: Time Series Visualization


  1. Time series have a special structure. Observations are ordered by time, and the relationships between nearby observations usually matter. This creates both challenges (structure at multiple scales — daily, weekly, annual, trend) and opportunities (readers already understand time and bring intuitions about cycles and change).

  2. Datetime axis formatting requires explicit locators and formatters. Use matplotlib.dates (YearLocator, MonthLocator, DateFormatter) or Plotly's tickformat and dtick to control tick density and label format. Automatic defaults are usually acceptable but often benefit from tuning.

  3. Rolling means reveal trend beneath noise. Simple moving averages (df.rolling(window=N).mean()) smooth short-term variation. Exponential moving averages (df.ewm(span=N).mean()) give more weight to recent observations. Window size is a design choice — match it to the phenomenon you are studying.

  4. Seasonal decomposition separates the three components. statsmodels' seasonal_decompose and STL break a time series into trend + seasonal + residual. Visualize as a 4-panel stack (observed + each component). STL is more flexible and handles evolving seasonal patterns better.

  5. Annotations turn data into narrative. Use axvline, axvspan, and annotate to mark events, regimes, and anomalies on time series charts. A well-annotated chart tells a story; a raw chart is just data. Keep event lists in a separate DataFrame for reuse across charts.

  6. Calendar heatmaps compress daily data into compact 2D views. calplot (or manual matplotlib) shows weekly cycles, seasonal patterns, and individual day outliers in a single scannable image. Underused in business dashboards; worth considering for any daily metric review.

  7. Cycle plots reveal seasonal-vs-trend interactions. One panel per season (month, quarter), each showing values across years with a reference line. Answers "which seasons are trending how?" — a question neither line charts nor decomposition alone can answer directly.

  8. Sparklines are word-sized time series. Introduced by Tufte in 2006. Remove all chrome (axes, labels, legend) and embed alongside text or in compact dashboard grids. Useful when you need to show many metrics without using many large charts.

  9. Aspect ratio matters. "Banking to 45 degrees" (Cleveland's principle) means choose a chart width where the average slope is near 45 degrees. Wide charts are usually right for long time series; square is right for short volatile ones. Trend perception depends on aspect ratio as much as on the data.

  10. Time series pitfalls are specific and common. Dual-axis abuse (manufacturing visual correlation), non-zero baselines for area charts, misleading smoothing that hides events, invisible missing-data gaps, irregular sampling creating false density, and confusing x-axis zero. Each has a specific remedy; know them.


Chapter 25 is the first chapter of Part VI (Specialized Domains). Time series are the most common specialized data type — most dashboards, most scientific papers, most business reports include time series charts. The techniques in this chapter are the vocabulary for that work. Chapter 26 continues Part VI with text and NLP visualization.