Time series data is easy to display as a line chart, but drawing an interesting story out of the data may be difficult without additional description or clever labeling. One option, however, is to add regions to your time series charts to indicate historical periods or visualization binary data.

Here is an example where a chart of annual U.S. national economic indicators has been enhanced with regions that also indicate contractions in the U.S. business cycle – roughly speaking, economic recessions.

A time series with colored regions in the background, created in Excel.

To create this chart, all of the indicators were averaged by year and, where necessary, adjusted for inflation using a conversion factor. Download the time series data Excel file for the data and the chart to follow along.

First, to set up the basic line chart, hold Ctrl (PC) or Cmd (Mac) while you select the following columns:

  • D (stock price index over CF…)
  • E (avg. annual unemployment…)
  • G (GDP over CF…)
  • I (debt over CF…)
  • K (interest rate * 10)
  • L (years economy is in decline)

Youll notice that the columns are color coded. Some colors apply to multiple columns; this is because the values that appear on the chart have been calculated by transforming the raw data in some way. Each line on the final chart thus corresponds to one or more columns of data used to produce the values. Transforming the values helps us by normalizing the values (i.e., adjusting for inflation) or scaling the data series itself (making it possible to see the relationships between many different indicators on a single graph, despite wide variations in the ranges of values).

When we select the six columns above and insert a line chart, we get a rather ugly line chart.

The chart as it looks with the default Excel settings.

We’ll make several changes to improve this:

  • Change the “years… in decline” series to an area chart
  • Select and adjust the x axis labels and ticks
  • Adjust the y axis range
  • Customize the color, label, and order of the data series

The basic mechanism of the colored regions on the chart is to use Excel’s “area chart” to create rectangular areas. The area chart essentially takes a line chart and fills the area under the line with a color. If we have a continuous horizontal line as a data series, we will create a large colored rectangle on the chart. To have breaks in the rectangle, we simply need to leave some of the years blank (without values in the cells). To select the appropriate values for column L, we first found the maximum value for the other data series and determined that a value of 20 would create bars starting above the other data series.

To produce the colored regions that indicate contractions in the business cycle, we take the series that was created from column L and turn it into an area chart.

  1. Right-click on any data point in the series or on the legend entry
  2. Select “Change Series Chart Type…”
    Changing the chart type for a particular data series.
  3. Select the standard Area chart from the ribbon
    Select Area from the ribbon.

The chart now fills in the area under the original lines with a default fill color.

After changing one series to an Area chart.

At this point, you can right click on the series again, select “Format Data Series…”, and change the Fill color to a light gray.

Changing the fill color of the Area series.

Next, we tell the x axis what the correct labels are (the “Year” column) and have the labels show up every 4 years. (Our data series start on an election year, so the labels will always appear on election years.)

      1. Right click inside the chart somewhere and select “Select Data…”
      2. Select any of the data series in the “Series” list, then go over to the “Category (X) axis labels” box and select the “Year” column. Click “OK”.
        Changing the X axis labels.
      3. Right-click on the x axis and select “Format Axis…”.
      4. Under “Scale”:
        1. Change the default interval between labels from 3 to 4
        2. Change the interval between tick marks to 4 as well
        3. Uncheck the box next to “Vertical axis crosses between categories”
          Changing the X axis scale.
      5. Under “Text Box”, select the text direction of “Rotate to 90 deg Counterclockwise”. Click “OK”.
        Changing the X axis text.

The x axis should have appropriate year labels now. The y axis can similarly be adjusted to show just the range of values we’re most interested in.

      1. Right-click on the axis and select “Format Axis…”.
      2. Under “Scale”, unselect the check box next to “Maximum:” and change the value to 20.
        Changing the Y axis scale.

The rest of the changes are simply formatting changes. Right-click on the individual data series to change the colors, line widths, etc. Use the formatting options or the Chart tools on the Excel ribbon to change the font of any text, adjust the grid lines, add labels and titles, etc. The data series names in the legend can be adjusted by using the “Select Data…” option and typing in custom text in the “Name” field.

The final product should have colored regions and look something like the chart below.

A time series with colored regions in the background, created in Excel.

In another post, we will show how to spice this chart up even more using Adobe Illustrator.

 

4 Responses to Adding Colored Regions to Excel Charts

  1. Philip Ward says:

    This is very useful. Do you have any idea on how to do this on the Y-axis? (E.g.. in you example, to produce a horizontal bar between y=4 and y=6). I tried to by going up to the “area chart” option to get a vertical highlight like the ones here, then I would have wanted to swap the axes, but Excel seems to eliminate the X-axis values in the process, even in X-Y scatter charts. All I could do was add a semi-transparent rectangle as a drawing object.

  2. Angela Zoss says:

    Hello Philip,

    Good question! I went ahead and played around with creating horizontal bars, and I ended up using stacked area charts. First, you want a series that represents the bottom of the lowest bar (perhaps “2″ on the above chart). To prepare the data for that series, just add a new column and put a “2″ in every row. The next new column should be the height of the horizontal bar – so, if you want the top of the bar at “3″, you would put “1″ in every row instead of “3″. You could do this again for another horizontal bar – say, add a column of “2″s to skip up to “5″ for the bottom of the new bar, and another column of “1″s to make that bar 1 unit tall.

    After you add these columns to the chart, you should start out with a bunch of horizontal lines in the wrong places. You have to select those lines and change the chart type to Stacked Area. You might have to play with the order of the series, but once the tops and bottoms of the bars are in the right places, you can select the bottom-most horizontal bar (the one going from 0 to 3, the one you *don’t* want to have on the chart) and change the fill to “no fill”. It should turn transparent but not get deleted. You can do this again for the bar between 3 and 5.

    Hope that helps!

    Best,
    Angela

  3. Arie says:

    Hi Angela,

    This is very useful but I noticed that any periods with only one year of recession don’t show in the chart (2001, 1970, 1945). What do you need to do to make sure that these shows as well?

  4. Angela Zoss says:

    Thanks so much for the great question, Arie. You’re absolutely right, the single years aren’t showing up here. In fact, all of the bars are basically showing one fewer year than they should. This technique is specifying a start date for the bars (the top-left corner of the bar), but not an end date (the top right corner), and for contraction cycles that oscillate quickly, the data structure here just isn’t going to be able to capture that.

    I wish I had a quick answer, but it looks like the best way to produce the true width of these bands is to follow the instructions for a stepped chart on the Peltier Tech Blog – basically, make a copy of the data and then offset that copy by deleting the earliest year and the latest data value. I did this with the sample data – including all years, either those with a value 20 or those with no value – and was able to produce an area chart that showed the single years as well.

    The problem with this method is all of the other line series that go on top of the area chart. I haven’t been able to achieve the combination chart yet, but my guess is that it would be easiest to duplicate the full data table when preparing the area chart, instead of just the contractions data. The problem I ran into is that now that there are duplicate dates in the contractions data, I’m having trouble getting the x-axes to match up between the line series and the area chart.

    Another thing to note is that right now I’m playing with this on a Mac using Excel 2011. The new Excel 2013 for Windows seems to have good functionality for multiple axes, perhaps even multiple horizontal axes.

    Thanks for the great question, again! I hope this hints at a possible solution for a significant flaw in the proposed method.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>