In Part 1, we learned that in Tableau we can create two types of Color Palettes
- Regular – Used for Dimensions and Discrete Fields
- Sequential – Used for Measures or Continuous Fields
Creating Custom Sequential Color Palette:
Step 1: We have created the Custom Regular palette in
Continue the steps after this:
Launch Tableau Desktop and Connect to ‘Sample Superstore Data.Xls’. Learn how to connect to excel data source
Step 2: Select the Orders table to create a Map – Use State from Dimensions and Sales from Measures.
Step 3: Create a Map using the above fields and place the Sales field to the Colors Shelf.
In the above sheet, you can observe Tableau by default allocates some Color Palette to the Map.
Step 4: We can change the color palette of Map, by clicking on Colors shelf and select the Edit Colors Option.
In the Palette option, we can see multiple Color palettes provided by Tableau. We can select any one from the list and assign to the Map.
If you don’t want to go with Tableau provided Color Palettes and would like to create your own custom palette, use Preferences.tps file.
Step 5: Save the Workbook and close Tableau Desktop.
Step 6: Navigate to ‘My Tableau Repository’ Folder under \ \Documents \My Tableau Repository, and open Preferences.tps in Notepad.
Note: This contains XML script. It can only be open in a text editor, such as Notepad.
Step 7: Use the following XML script to create Custom Color Palette using HTML codes of 6 Colors.
<color-palette name=”Custom Regular Palette” type=”regular” >
<color-palette name=”Custom Sequential” type=”Ordered Sequential” >
Step 8: Copy the above Code into the preferences.tps file. Save and close the file.
Note: This code will create Custom Color Palette. Notice type= ”Ordered Sequential” this will create Sequential Color palette to be used with Continuous or Measure data elements.
*** We are adding the ordered sequential palette code to already existing regular type code. We can add as multiple color codes in the preferences.tps file.
Step 9: To see the Custom Color palette in Tableau, Close the Tableau desktop Application by saving the workbook and restart the application.
Open the saved workbook to apply Created Custom palette for the Map. Follow the same steps of Selecting the Colors Shelf and opening the Edit Colors Option.
Select the ‘Custom Color palette’ present at the bottom in the list of Palette option and assign the palette.
It Shows the below colors for the Map.
Please see step by step video below: