February 3, 2014

Tableau Tip: Make great looking band lines with area charts

When I was in Israel last week, we wanted to create a visualization that included band lines based on confidence intervals in the database.  In other words, our table contained two measures: value and confidence interval.

Allen Smithee had created some interesting looking Bollinger Bands before, so I started there.  I downloaded the workbook and noticed that while these look decent, they’re not perfect.  This is the initial view:

image

Looks pretty good.  But when you remove the lines for the upper and lower bands (or if you zoom in), you will see that the bands were made via reference bands for each discrete date, which makes them look like bars.  I suspect the lines for the upper and lower were included to hide the rough edges of the bars.

image

Here’s how he created the reference lines:

image

I don’t think this looks polished enough, so I took an alternative approach: area charts.

I started by downloading some stock data from Google for various tech stocks for the past year.  Next I created four calculations that I needed for Bollinger Bands.

image    image

image    image

Next I created a simple line chart across a continuous date dimension using the Moving Avg Close calculated field.

image

Now onto creating the bands.  I want these to be an area chart on the secondary axis.  I dragged the Bollinger Lower Band measure onto the secondary axis.

image

Then drop the Bollinger Band Width measure onto the secondary axis as well and synchronized the axis.

image

Next, right-click on the secondary axis and change the Mark Type to Area Chart.

image

All that’s left is a bit of formatting. 

  • Remove the gridlines
  • Hide the header for the secondary axis
  • Change the color of the area chart sections: make the bottom section white and the top section gray
  • Change the color of the Moving Avg Close line to red
  • Move the primary axis to the front
  • Remove the column and row borders

image

I then repeated this exercise with a standard deviation calculation so you could see two types of bands.  I suspect you agree that these look much more polished.

Download the sample workbook here.