Tableau provides awesome visualizations and color palettes.
Tableau provides multiple color palettes, but in case you have to create your own custom color palette, use preferences.tps file.
Why use Preferences.tps file ?
Prefrences.tps file can be used to create consistent colors across the enterprise. It is also useful when developer has to use colors which are discontinued by Tableau in the new versions of Tableau desktop.
Types of Color palettes in Tableau
There are 2 types of Color palettes in Tableau:
Regular: Used for Dimensions or Discrete Fields
Sequential: Used for Measures or Continuous Fields
How to use colors in Tableau
Step 1: 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 Bar Chart – use Sub-Category from Dimension and Sales from Measure.
Step 3: Create a bar chart using the above fields and place the Sub-Category Field to the Colors Shelf.
In the above sheet, you can observe Tableau by default allocates some Color palette to the Chart.
Step 4: We can change the color palette of chart, by clicking on Colors Shelf and Select the Edit Colors option.
In the Select Color Palette option, we can see multiple Color palettes provided by Tableau .We can select any one from the list and assign to the chart.
If you don’t want to go with the Tableau provided Color Palettes and would like to create your own custom palette, use Prefrences.tps file.
Steps to create Regular Custom Color Palette in Tableau
Step 5: Close Tableau Desktop.
Step 6: Navigate to ‘My Tableau Repository’ Folder under \\Documents\My Tableau Repository, and open Preferences.tps extension 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 17 Colors.
<color-palette name=”Custom Color Palette” type=”regular” >
Copy the above Code into the prefernces.tps file. Save and close the file.
Note : This code will create Custom Color Palette. Notice type=”regular” this will create Regular custom color palette to be used with Dimensions or discrete data elements.
Step 9: To See the Custom Color palette in Tableau, Close the Tableau Application by saving the workbook and Restart the application.
Open the saved workbook to apply the Created Custom Palette for the chart. 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 Select Color palette option and assign the palette.
It should show this below Colors for the Chart.
Please see step-by-step video below
In the next blog, i will cover how to create Sequential color palette in Tableau.