Data Viz Done Right

June 17, 2015

Tableau Tip Tuesday: Showing an Axis Above a Chart

A very common question and feature request I see on the Tableau Forums is to show the axis above a chart rather than below, as Tableau does by default.

When I was working on solving this, I started by looking at the XML for a workbook and there is a bit of code that controls whether an axis displays. I built a dual-axis chart to see if I could change the display in the code.

In the <style> section, note the value=‘false’ setting. This is what is hiding the axis. I changed only the top axis by setting it to ‘true', but when I opened the workbook again, both axes were displayed. Back to the drawing board I went.
Here are the steps to follow to display the axis above the bar chart and not below (sort of):
Step 1: Create a bar chart.

Step 2: Duplicate the measure that is shown in the chart by right-clicking on the measure in the Measures list and choosing Duplicate.

Step 3: Drag the duplicated measure onto the secondary axis.

You should now have a chart that looks like this:

Step 4: Change the mark type for both measures to Bar.

Step 5: Remove the Measure Names field from the Color shelf. This isn’t required, but you really don’t need to have two colors for the same measure.

Step 6: Right-click on the bottom axis and choose Format. Change the Font to white and set the Ticks to ‘None’. This doesn’t hide the axis (hence the reason I said ’sort of’ above), but it will give the appearance that the axis isn’t there.

Note: The reason that you have to duplicate the measure has to do with how formatting works. If I used the same measure again for the secondary axis (i.e., Sales in this case), then when I format Sales, it applies to both axes. However, when you duplicate the field, Tableau treats it like a totally separate measure with its own formatting.

Step 7: Double click on each of the axes and remove the titles. This isn’t required, but it makes the axis narrower.

That’s it! While this isn’t a perfect solution, it works. Also, be sure to clean up the tooltips since they will show the measure twice.
You can download the workbook used to create this viz here.