VizWiz

Launch, grow, and unlock your career in data

February 3, 2014

Tableau Tip: Make great looking band lines with area charts

18 comments

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.

18 comments :

  1. how do you embed your dynamic visualizations in blogspot? I can't seem to get it right.

    ReplyDelete
    Replies
    1. Use the embed code from the Share button after you publish to Tableau Public.

      Delete
  2. I don't have Tableau loaded on my computer lab at school, but I'm trying to get some viz activities going for my class in the meantime with Google Charts. Is it likely the same process?

    ReplyDelete
    Replies
    1. Steve, I don't know enough about Google Charts to answer your question. As an educational institution, you get Tableau for free if you want to use it in your class. This link has all of the details - http://www.tableausoftware.com/academic/students

      Delete
  3. This is a sweet improvement, thank you for this! When I get some time I'm going to update my post and link here. Nice one!

    ReplyDelete
  4. The only issue I ran into was eliminating the zero-reference on the primary axis. I selected "no zero", but the axis always includes a zero reference. Anyway of correcting this?

    ReplyDelete
    Replies
    1. No, you have to include 0 for the stacking to work properly.

      Delete
  5. How would you approach this using Number of Records and where your data set is at a lower grain then what you're displaying in your time series? I'm trying this and getting a Moving Avg of 1

    ReplyDelete
  6. You just made my job more fun - I took annual miles driven and turned the line chart into a road.

    ReplyDelete
    Replies
    1. That sounds awesome Cathy!!! Did you publish it?

      Delete
  7. This is the most helpful post I've been able to track down to create bands like this. I am hitting 2 problems though, and I'm wondering if you've got any suggestions. I need to plot 2 lines against the band: median performance, and my group's performance. It looks like Tableau only allows one line to be plotted at a time. The second issue is that my area chart has negative values. Tableau doesn't chart stacked area values correctly for negatives. All area chart values are on one side of the x-axis, so there is no way to show the values spanning both sides of the x-axis.

    Thanks for any thoughts. I'm getting super frustrated with Tableau for anything other than simple charts. I had this chart done in five minutes in Excel and I'm on day 3 in Tableau... I'm hoping the learning curve gets faster.

    ReplyDelete
    Replies
    1. Mike, you can plot as many lines as you want on the same axis by dropping the 2nd, 3rd, etc on top of the existing axis. This will then change the axis to the Measure Values field and will reveal the Measure Values shelf.

      Delete
  8. These are some of The most helpful and easy to follow instruction videos I have found. Great job Andy - please keep it going.

    ReplyDelete
  9. Andy - one question. The note above says that you can add multiple lines to the chart (i.e. show multiple lines within a band) but this doesn't seem to be working for me. I want to be able to display actual sales and planned sales within a 5yr high-low banding. Is it possible to do this?

    ReplyDelete
    Replies
    1. Hi David. Depending on your method, you should be able to do it. If they are separate measures, then you put them on a combined axis. However, you would then need to make sure the banding part isn't also a combine axis because Tableau won't allow that. You would need to create some kind of calculation to make it work.

      Delete