ad

How to Create a Custom Color Palette in Tableau

Reference: Click Here
Tableau Desktop comes with a set of color palettes that have been carefully designed to work well together and effectively apply color to data in many situations, such as on maps, heat maps, bars, etc.,. Alternatively, you can add your own custom color palettes to match your corporate identity or to describe common data better.

In general, Tableau offers three types of color palettes: categorical, sequential, and diverging. You can create your own custom color palette by modifying the Preferences.tps file that comes with Tableau Desktop. The Preferences.tps file is located in the My Tableau Repository. The preferences file is a basic XML file that you can open in a text editor to modify. Unedited preferences file looks like following example:

Important: Tableau does not test or support custom color palettes, so be sure to back up your workbooks before you continue. Also, there is no guarantee that your custom color palettes will work with future Tableau Desktop upgrades. 

You can add as many custom palettes as you like, each with as many colors as you want. Make sure each palette has a unique name. The colors are indicated using the standard HTML format. This is the hexadecimal value #RRGGBB or Red Green Blue format. When you save the workbook, the color information is embedded in the file, but it is not included as a reusable color encoding. This means that any colors that are in use are shown for anybody opening the workbook; however, if they don't have the modified preferences file, they cannot use the color information for new color encoding.
Step 1: Edit your preferences file
  1. Go to the My Tableau Repository folder in your Documents directory, and open the Preferences.tps file.
  2. Between the opening and closing "workbook" tags, insert opening and closing "preferences" tags.

  1. Choose a color palette option below and follow the procedure to modify the Preferences.tps file.
Option 1: Create a custom categorical color palette
A categorical color palette contains several distinct colors that can be assigned to discrete dimension members. For example, when you put a discrete dimension such as Region on the Color, the categorical color legend is used. The following is an example of what to add between the "preferences" tags to add a categorical color palette. Note that the "type" attribute is specified as regular, which identifies this palette as a categorical palette.

  1. In the Preferences.tps file, between the "preferences" tags, paste the following:
<color-palette name="My Categorical Palette" type="regular" >
<color>#eb912b</color>
<color>#7099a5</color>
<color>#c71f34</color>
<color>#1d437d</color>
<color>#e8762b</color>
<color>#5b6591</color>
<color>#59879b</color>
</color-palette>
  1. Save the Preferences.tps file and then restart Tableau Desktop.
  2. Open the Superstore sample data source.
  3. From the Dimensions pane, drag the selected discrete dimension (e.g., Region) to Color.
  4. Click the color legend menu arrow and select Edit Colors.

  1. In the Edit Colors dialog box, from the palette drop-down list, select your new custom palette.

  1. Click the Assign Palette button to assign the custom colors to each respective field.
  2. When finished, click OK.

Option 2: Create a custom sequential color palette
Another type of palette is the sequential color palette. Typically, this type of palette shows a single color, varying in intensity. This type of color palette is used for continuous fields, typically for measures. The following is an example of what to add between the "preferences" tags to add a sequential color palette. Note that the "type" attribute is specified as ordered-sequential, which identifies this palette as a sequential palette. Also, for sequential palettes you must specify each variant of the color in the sequential color range.

  1. In the Preferences.tps file, between the "preferences" tags, paste the following:
<color-palette name="My Sequential Palette" type="ordered-sequential" >
<color>#eb912b</color>
<color>#eb9c42</color>
<color>#ebad67</color>
<color>#eabb86</color>
<color>#eacba8</color>
<color>#ebd8c2</color>
</color-palette>
  1. Save the Preferences.tps file and then restart Tableau Desktop.
  2. Open the Superstore sample data source.
  3. From the Measures pane, drag the measure (e.g., Sales) to Color.
  4. Click the color legend menu arrow, and select Edit Colors.
  5. In the Edit Colors dialog box, from the palette drop-down list, select your custom palette.
  6. If you want each color gradation to be defined within a box, select the Stepped Color check box, and in the Steps text box, type the number of color steps you want to display in the bar.
  7. Click the Advanced button.
  8. Select the Start check box, and in the text box, type the low end number you want for the continuum.
  9. Click the Apply button to see the result, and make adjustments as needed. The default for sequential color is to make the high end of the continuum pale and the low end intense; select the Reversed check box to make the high end intense and the low end, pale (this is the default when you keep the Automatic palette selection).

Option 3: Create a custom diverging color palette
The third type of color palette is a diverging color palette. A diverging palette shows two ranges of values using color intensity to show the magnitude of the number and the actual color to show which range the number is from. Diverging palettes are most commonly used to show the difference between positive and negative numbers. The following is an example of what to add between the "preferences" tags to add a diverging color palette. Note that the "type" attribute is specified as ordered-diverging, which identifies this palette as a diverging palette.

  1. In the Preferences.tps file, between the "preferences" tags, paste the following:
<color-palette name="My Diverging Palette" type="ordered-diverging" >
<color>#eb912b</color>
<color>#59879b</color>
</color-palette>
  1. Save the Preferences.tps file and then restart Tableau Desktop.
  2. Open the Superstore sample data source.
  3. Click the Assign Palette button. The colors in the palette are used in the order they appear in the Preferences file.

If you add a sequential or diverging palette, remember to change the "type" attribute from "regular" to one of the following:
  • ordered-sequential
  • ordered-diverging
Step 2: Assign a default custom palette to dimensions and measures and publish as a data source (optional)
After you save the workbook, the custom color palette information is embedded in the workbook (for Excel and text file-based workbooks, in the .twbx) and therefore only available for that workbook. This means that colors that are in use are shown for anybody opening that particular workbook. If they don't have the modified preferences file, they cannot use the color information for any new color encoding. To allow new color encoding using the custom color palette or to standardize a custom color palette for the Tableau workbooks in your organization, you can create the custom color palette using one of the options above, and then publish it as a Tableau Server data source.
  1. On the same computer from which you modified the Preferences.tps file, open Tableau Desktop.
  2. Open the Superstore sample data source.
  3. Right-click a field in the Data pane, and select Default Properties > Color.
  4. In the Edit Colors dialog box, associate the field values with the custom color palette, and then click OK when finished.
  5. From the Data menu, select the data source, select Publish to Server, and then complete process to publish the data source.

After publishing the data source to Tableau Server, connect any new workbooks to this data source to use the custom color palette.