Tableau Image Palette

Over the weekend I have spent some time developing an Alteryx application that takes you from this…

Ben Moss_2.jpg

To this…


(From a jpeg/png file to a custom colour palette in Tableau)

The tool is available here on the Alteryx Gallery but you will need to download the application as it contains an R script to extract the colours from the inputted image (Alteryx do not allow external scripts to run upon their public Alteryx gallery).

So how did I build it?

This is going to be a very brief overview because the majority of the steps can be found in this blog post, in terms of extracting the colours from the image and converting them into a Tableau friendly format.

Once I had identified the colours which I would wish to inject into my Tableau preferences file then I need to actually inject them into my Tableau preferences file.

In order to do this we first need to input our Tableau preferences file into the Alteryx workflow. As with Tableau workbooks, Tableau preferences file’s are XML documents and as a result we can read them into Alteryx in the same way as shown in this post.

The XML structure of the Tableau preferences file is fairly simple and can be seen in the image below. We have an opening tag for each colour palette which identifies the name and the type (type being ‘categorical’, ‘custom sequential’ or ‘custom diverging’; note in the case of this application our colour palette will always be of categorical type).


You then have the colours which you wish to insert into the palette, enclosed by an opening and closing set of tags.

And finally you have a closing tag to identify the end of your custom colour palette .

So first things first we need to build our tags around each of the colours we wish to bring into the palette, this can be done with a simple formula.

” <color>”+[HexCode]+”</color> ”

([HexCode] being the field which contains the hexidecimal representation of each of my colours).

We then need to bring in our opening and closing tags for the entire colour palette which can be done using a text input and then unioning our streams together.


Now we have the XML required for our new custom colour palette, it is just a case of unioning this into our current colour palette.


If you are more curious then feel free to take a more in-depth look at the workflow once you have downloaded the application.

So how do I use the application?

The user interface for this application is fairly simple and hopefully makes sense to users. I made a few advancements as a result of gathering feedback from my colleagues at The Information Lab.

Users simply need to navigate to their chosen image (in order to do this, when the file browse opens you must select ‘All Files’ from the ‘Files of Type’ drop down).

Select the number of colours they wish to have in their final colour palette, enter a name and then finally select the preferences file which they wish to inject the colours into.




Once you have run the application and ensured your Tableau preferences file is in the correct location (C:\Users\You\Documents\My Tableau Repository) then after restarting Tableau your colour palette should be available to assign when you have dimension fields on the colour shelf.

Note, this application is only on a V1 release so any feedback you have will be much appreciated, and please let me know if you receive any bugs.


Current known issues

  1. R script error relating to missing packages.Reason: this is likely due to R not being able to communicate with the CRAN mirror ( that has been given in the R script in order to download dependant packages.Resolution: Within action tool 34, amend the CRAN mirror given in each of the install.packages() functions (there are 6 in total), to one more appropriate for your location. A list of available CRAN mirrors can be found here.