ART + MATHEMATICS: USING TABLEAU TO DRAW MATHEMATICAL CURVES

Rajeev Pandey
5 min readJan 18, 2021

--

Blog Contributor/Author: Joti Gautam

HOW IT ALL STARTED?

I have been using Tableau from the past seven months and know the basics of it. I regularly go through a lot of amazing visualizations by Tableau Zen masters and other talented authors over Tableau Public which are not only analytically great but also appealing from the design perspective and the creativity involved in them. So, I wanted to get the base level understanding of how the custom charts and designs are built-in Tableau (like the starting point of the Universe’s evolution in Big Bang). I started checking blogs on it and then I came across the “Beyond Show Me” three-part series by Ken Flerlage. Thanks to Ken for this amazing blog. I must recommend going through it to know how the x and y coordinates work in Tableau. As Ken did, I even tried creating the Modern Periodic Table in tableau to get the intuition about x,y points.

If that’s not enough to make you fall in love with Tableau, I have got more in store for you. Check my other blog post by clicking the below link.

DRAWING HUMAN FACE IN TABLEAU

PARAMETRIC EQUATIONS

In the last part of this series, Ken has described the parametric equations which I have used in my visualisation. Parametric equations can be well understood through his blog even if you don’t have a strong grasp on Mathematics and Trigonometry. I strongly recommend going through it before reading further here. From what I understand, parametric equations have a single parameter (which we call ‘t’) that can be used to get the x and y coordinates of any point on the curve and the value ‘t’ can be both positive and negative.

X and Y equations used in my viz (t ranges from -8 to 8):

LET’S START OUR VIZ

Data Preparation: For the data densification purpose, we need to prepare some data and I did it in Excel for clear understanding.

We have taken below two sheets each containing one column P and T.

T values range from -14 to 14 with the difference of 0.01.

P value ranges from 1 to 24.

We will describe them as we will use, please follow along.

Excel workbook can be downloaded from here. Go to File → Downloads → MS Excel

Load this data into tableau and start creating fields.

Calculated Fields:

X  = 6 * (SIN(9.52*[T (T)])) * (ROUND(SQRT(COS(COS(4.7*[T (T)])))))Y = 6*POWER(COS(9.52*([T (T)])),4)*SIN(SIN(4.7*([T (T)])))TMax = ABS([T (T)])<=8.5 (as per out t value for this equation)

Place X in rows and Y in columns on the sheet and change the chart type to line in Marks card. Place TMax in the filter and set it to True.

Now Place T on the line Path. We will get something like this:

Here I got one part of the beautiful design done but I needed to have this design rotated at various angles to create four folds to get our beautiful design. Again, flerlagetwins came to rescue and I stumbled upon a blog showing how to rotate the shapes.

So we will create some more calculated fields.

The above created X and Y fields will now be added to overall X and Y points which will define the angle to create this design. Here, we will use our sheet with the P column.

Index = [P]Angle = 360/4X_total =(ATTR([X])*COS(RADIANS([Angle]*ATTR([Index]))) -  ATTR([Y])*SIN(RADIANS([Angle]*ATTR([Index]))))Y_total =(ATTR([Y])*COS(radians([Angle]*ATTR([Index]))) +ATTR([X])*SIN(RADIANS([Angle]*ATTR([Index]))))

Now is the time for the final show-down. Place all the fields on a sheet as per below steps.

  1. Place MaxT over the filter shelf and set its value to True.
  2. Place X_Total and Y_Total on row and column shelves respectively and allow their table calculation to compute using the cell.
  3. Change the Marks type to Line and place T over Path.
  4. Put P field on Detail.

Now we will have our desired beautiful design:

After some formatting and polish, we will end up with the design used in my data viz.

I have created an interactive version of the visualization as well which you can check here.

https://public.tableau.com/views/Exploreitenjoyit/Dashboard1?:language=en&:display_count=y&:toolbar=n&:origin=viz_share_link

Don’t forget to share this article with others on Facebook, Twitter, LinkedIn, and Whatsapp! as it will help them and make my countless hours of work count. If you have any questions please do not hesitate to contact us on Twitter or LinkedIn.

If you enjoyed this blog , I’d love for you to hit the share button so others might stumble upon it. Please hit the subscribe button as well if you’d like to be added to my once-weekly email list, and don’t forget to follow Vizartpandey on Instagram!

Also, here are a few hand-picked articles for you to read next:

--

--

Rajeev Pandey

I’m Rajeev, 3 X Tableau Zen Master , 5 X Tableau Ambassador, Tableau Featured Author, Data Evangelist from Singapore