Chapter 14. Visualizing Trends
When making scatterplots (Chapter 12) or time series (Chapter 13), we are often more interested in the overarching trend of the data than in the specific detail of where each individual data point lies. By drawing the trend on top of or instead of the actual data points, usually in the form of a straight or curved line, we can create a visualization that helps the reader immediately see key features of the data. There are two fundamental approaches to determining a trend: we can either smooth the data by some method, such as a moving average, or we can fit a curve with a defined functional form and then draw the fitted curve. Once we have identified a trend in a dataset, it may also be useful to look specifically at deviations from the trend or to separate the data into multiple components, including the underlying trend, any existing cyclical components, and episodic components or random noise.
Smoothing
Let us consider a time series of the Dow Jones Industrial Average (Dow Jones for short), a stock market index representing the price of 30 large, publicly owned US companies. Specifically, we will look at the year 2009, right after the 2008 crash (Figure 14-1). During the tail end of the crash, in the first 3 months of the year 2009, the market lost over 2,400 points (~27%). Then it slowly recovered for the remainder of the year. How can we visualize these longer-term trends while deemphasizing the less important short-term fluctuations?
Get Fundamentals of Data Visualization now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.