Coloring your numbers

In this recipe, we will look at the use of color to convey a message. Since we are looking at dashboarding, we need to know how to use color effectively to make the most of a small space. Here, we will use a box and whisker plot to convey a lot of information about the data in a small space, along with additional information on the figures themselves using color.

Getting ready

For the exercises in this recipe, let's start with a fresh Tableau workbook. There are no other requirements for this recipe.

How to do it…

  1. Go to Tableau and navigate to File | New.
  2. Select the Connect to Data link at the top-left corner of the screen.
  3. Navigate to the DimProductCategory.csv file, which is located in the folder where you downloaded the code samples, and click on the Open button to import it into the Tableau workbook.
  4. When the Text File Connection dialog box appears, select the option Multiple Tables.
  5. Next, click on Add Table to import the file DimSubProductCategory.csv. The dialog box shown in the following screenshot appears:
    How to do it…
  6. Uncheck the column DimProductSubcategory #csv_ProductCategoryKey, as you can see in the preceding screenshot. Click on OK.
  7. When the Data Connection dialog box appears, select the option Import all data.
    How to do it…
  8. Now we will join the data together. Click on the Join button and you will see that the column ProductCategoryKey is the join for each table. Click on OK. Here is an example of the join clause in the following screenshot:
    How to do it…
  9. The Text File Connection dialog box will now look like the following screenshot:
    How to do it…
  10. Now, we will add the DimProduct file by clicking on the Add Table… button again and click on it once more for the DimProduct#csv table.
  11. Click on the Unselect All button. Tick only the following columns: EnglishProductName, ProductKey, and Color, and then click on Join. The join clause will show that there is a join between the ProductSubcategoryKey column for each table, and this is correct. Click on OK.
  12. The Text File Connection dialog box will appear as shown in the following screenshot. Rename the connection to DimProduct and click on Add Table….
    How to do it…
  13. Now, we will add in the FactInternetSales table by selecting it from the list of available tables in the Text File Connection dialog box.
  14. Choose the option Unselect All and select only the following fields: Sales Amount, Order Quantity, ProductKey, and OrderDate, and then click on Join.
  15. In the join clause on the left-hand side, make sure that DimProductCategory#csv is selected from the drop-down list.
  16. Select the ProductKey column for the DimProduct table from the left-hand side of the join clause.
  17. Make sure that FactInternetSales#csv is on the right-hand side of the join clause in the drop-down list.
  18. On the right-hand side, select ProductKey from the FactInternetSales table and set the join type to Inner. Click on OK.
  19. Next, let's add the table DimDate#CSV by selecting it from the list of tables in the Text File Connection dialog box.
  20. In the join clause, select FullDateAlternateKey for the DimDate table and OrderDate for the FactInternetSales table.
  21. In the Text File Connection dialog box, click on the DimDate#CSV table and then click on Unselect All.
  22. Select only the following fields: Max year, FullDateAlternateKey, FiscalYear, FiscalSemester, and FiscalQuarter.
  23. Click on the Join button to connect FullAlternateDateKey from DimDate#CSV and the FactInternetSales#csv column OrderDate.
  24. In the Data Connection dialog box, click on Import all data. You should now see the Tableau worksheet with your data source on the left-hand side. Rename the data source to Chapter Seven.
  25. Drag SUM(SalesAmount) onto the Columns shelf.
  26. Drag EnglishProductCategory onto the Rows shelf.
  27. Select the box-and-whisker plot from the Show Me panel.
  28. You'll see that the selected dimensions and measures change. Click on the Swap button after navigating to Map | Format. The screen will look as shown in the following screenshot:
    How to do it…
  29. Drag EnglishProductCategory back onto Rows.
  30. Drag Year(FullDateAlternateKey) onto the Marks shelf.
  31. Filter Year(FullDateAlternateKey) so that only the year 2008 is selected. Drag Year(FullDateAlternateKey) onto the Filters shelf. In the pop-up dialog box that appears, select Years.
  32. In the Filter[Year of FullDateAlternateKey] editor box, deselect 2005, 2006, and 2007. Leave only 2008 checked and click on OK.
  33. Drag SUM(SalesAmount) onto the Rows shelf.
  34. Right-click on the SalesAmount axis and deselect Show Header.
  35. Select Circle from the drop-down list on the Marks shelf.
  36. Drag SUM(SalesAmount) onto the Size button.
  37. Click on the Size button and move the slider so that it is half way between the start and the end of the slider. This will increase the size of the circles for SalesAmount.
  38. Drag SUM(SalesAmount) onto the Color button.
  39. Click on the Color button and select Edit Colors….
  40. From the drop-down list, select Red-Blue Diverging and click on Apply, and then click on OK.
  41. Reduce the size of the rows by clicking down and pressing on one of the Rows lines and dragging it upwards.
  42. Right-click on the box-and-whisker plot and select Edit….
  43. In the Edit Reference Line, Band or Box dialog box, go to the Formatting section and choose Glass for the Style setting.
  44. Set Fill to be white from the drop-down list.
  45. For the border, select the thinnest border from the available selection.
  46. For Whiskers, select the middle option. You can see an example of the settings in the following screenshot:
    How to do it…
  47. The final result appears as shown in the following screenshot:
    How to do it…

How it works…

Ever played with a Rubik's cube? Color is a vital way of understanding and categorizing what we see. We can't order colors in terms of low to high value, for example, red plus yellow gives blue, since people experience colors differently. However, we can use color to tell a story about the data. We can use color to categorize, order, and display quantity.

In this recipe, we chose color to highlight some elements over others, and we also used it to convey a message. Red was used to denote smaller values, and blue was used to denote higher values. Red is often seen as a warning color in the West. We reduced the color intensity in the box-and-whisker plot so that the circles could be seen through them. This allows us to add visualizations on top of one another but not occlude one another. The users can click on the box-and-whisker plot to get more detail about the data.

Data visualization is about displaying high-dimensional data onto a low-dimensional canvas. Color can help us to distinguish between the dimensions that you want to display. Bright colors pop at us, and light colors recede into the background. We can use color to focus attention on the most relevant parts of the data visualization. This is very important when we are dealing with Big Data sources. We tend to spot things that stand out.

In Tableau, we can see that there are a number of ways in which we can choose colors. Further, more we know that a percentage of the population is color blind, so their color perception is reduced. We can choose colors that feel natural, thereby bringing the dashboard closer to the viewer, and they can understand it better. Fortunately, Tableau often helps you to choose the right type of color for the data.

Color choice depends on the numbers that you are trying to represent. If you are looking at ordering data, you can choose a sequential palette. This is where you choose one color to reflect the metric, but the intensity, brightness, or darkness of the color increases as the value increases. You may want to use a sequential palette to represent age, for example, where lighter values represent younger age groups and darker colors represent older age groups.

Alternatively, if you are looking at distinguishing metrics, you could use a diverging palette. For example, the diverging palette could diverge from red right through the spectrum to white and then on to blue. This palette could be used to represent profit and loss, for example, white could represent zero or thereabouts, red could indicate a loss, and blue could indicate profit.

If you are looking at categorizing data, you could use different colors to represent different dimensional attributes. For example, you could use a different color to represent a different country or a different product group.

Picking color isn't easy. We can't say precisely that this color of blue is twice as blue than another shade of blue. However, Tableau does give you a helping hand.

See also

If you want to know more about color choice and theory, there are plenty of resources. Here are some good places to start:

  • Show Me the Numbers, Stephen Few, Analytics Press (2012)
  • Now You See It, Stephen Few, Analytics Press (2009)
..................Content has been hidden....................

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