Creating box plots

Box and whisker plots, also known as box plots, show the distribution of the observed measure. This distribution includes the 25th, 50th, and 75th percentile as well as the minimum and the maximum values of the measure. A box surrounds the interquartile values of the 25th, 50th, and 75th percentile, and whiskers represent the minimum and the maximum values. Since Tableau does not support creating a box plot directly, this recipe is a workaround to create a box plot in Tableau.

Getting ready

Let's use the sample file, Sample – Superstore Sales (Excel). Open a new worksheet and select Sample – Superstore Sales (Excel) as the data source.

How to do it...

Once the data is loaded, perform the following steps to create a box plot of shipping cost by container types:

  1. Drag-and-drop Container from Dimensions into the Rows shelf.
  2. Drag-and-drop Unit Price from Measures into the Columns shelf.
  3. Click on the Analysis menu option from the top toolbar and uncheck Aggregate Measures to remove aggregation.
  4. Right-click on the x axis and click on Add Reference Line, as shown in the following screenshot:
    How to do it...
  5. Click on the Distribution pane in the Add Reference Line options box.
  6. Select the Per Cell button under Scope.
  7. Under Computation, in the Value drop-down selection, select Quantiles and keep the Number of Tiles value to 4, as shown in the following screenshot:
    How to do it...
  8. Under Computation, in the Label drop-down selection, select None.
  9. Under Formatting, in the Line drop-down selection, select the first thick and solid line.
  10. Under Formatting, check the Symmetric formatting box as shown in the following screenshot:
    How to do it...
  11. Under Formatting, in the Fill drop-down selection, keep the default gray color, which is in the first column and fourth from the top.
  12. Hit OK.
  13. To add whiskers for the minimum values, right-click on the x axis and click on Add Reference Line.
  14. Keep the Line pane selected.
  15. Select the Per Cell option under Scope.
  16. Under Line, in the Value dropdowns, select Minimum as shown in the following screenshot:
    How to do it...
  17. Under Line, in the Label dropdown, select None.
  18. Under Formatting, in the Line dropdown, change the line color to red.
  19. Hit OK.
  20. Follow steps 13-19 to add the maximum whiskers, and instead of selecting Minimum, select Maximum in step 16. The final box plot should look like the one in the following screenshot:
    How to do it...

How it works...

Although Tableau does not provide a quick way to create box plots, adding reference lines is a very powerful feature that can be used to create box plots. Adding reference lines can be very useful for the reader to observe trends, distributions, and variance. In the case of box plots, we added reference distributions using quantiles (also known as quartiles) and added minimum-maximum lines.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset