In my previous blog post, I discussed the process of extracting coordinate information from SVG images and preparing the data for drawing polygons in Tableau. Now, let’s bring it all together and see how to draw the polygons in Tableau.

You can download a copy of the workbook here.

Drawing Polygons

Connect to the data that contains the coordinates, path, and grouping of the polygons we will be drawing.

Create a new sheet and change the Mark type to Polygon. Add the [Group] field to the Color mark, and [Path Num] field to the Path mark.

You’ll want to put your X coordinates in Columns, and Y coordinates in Rows. The type of aggregation does not matter, so I’ll leave it as the default.

At this point, if you have numbered your polygon groups in the same order they were listed in the SVG file, your polygon probably came out looking something like this:

 

Rendering Sequence

This issue we are facing reveals a discrepancy between the rendering sequence of SVG images and Tableau.

Consider each polygon as a separate layer in the image. In SVG, objects are layered from back to front, where objects in front overlap those in the back. On the other hand, Tableau follows a front-to-back layering order, with the first polygons added appearing on top. To ensure accurate representation, we need to reverse the drawing order of our polygons in Tableau.

Simply right-click on the [Group] pill in the Marks card, select Sort, and switch the Sort Order from Ascending to Descending.

And you’ll see this:

 

Applying the Colour Palette

Now we are faced with the daunting task of adding colour to 54 different polygons in this image.

In the previous blog post, we extracted the color palette from the SVG file, preserving the original order and including any duplicate colors.

The color palette will be available as an option in the Colors mark.

When selecting Assign Palette, Tableau simply assigns the colours in the the palette to the items in a dimension in the listed order.

 

By leveraging this feature, we can easily apply the correct color to each polygon. Just remember to clear any previous sorting before applying the color palette.

Put it all together, and we should have this:

And voila! There’s your very own Porygon, brought into Tableau from an SVG image.

Here’s my version of Porygon on Tableau Public.

The Data School
Author: The Data School