3 Replies Latest reply on Feb 1, 2018 9:02 AM by patrick.byrne.0

# Using TabPy to make a Normal Curve

I have before made Normal curves using the amazing blog by Robin Kennedy:

https://public.tableau.com/en-us/s/blog/2013/11/fitting-normal-curve-histogram

But when it comes to TabPy, I am failing to do so. As using Python codes inside Tableau needs some tweaking to do, some of the basic functions of Python fail in Tableau.

Even if I go step by step with the blog and manipulating the code as TabPy needs me to work, the final formula to make the curve -

(1 / ([St Dev] * SQRT(2*PI()))) * EXP(-((ATTR([Profit Bin]) – [Mean])^2 / (2*[St Dev]^2))) * [Profit Bin Size]* TOTAL (SUM([Number of Records]))

is rather getting difficult for me to recreate.

What I wrote till now is -

SCRIPT_REAL("

import numpy as np

import matplotlib.mlab as mlab

import math

sigma = maths.sqrt(_arg1)

x = np.linspace(_arg2 - 3*_arg3, _arg2 + 3*_arg3, 100)

", FLOAT([Variance]), FLOAT([Mean]), FLOAT([Std Dev]) )

Will it be possible to help me make the graph?

I have made the histogram using Tableau bins but I need to make the curve using Python.

• ###### 1. Re: Using TabPy to make a Normal Curve

Hello Pragyan,

I have moved this question into our Developer portal to give it better visibility to Tableau Community members that will most likely be able to assist.

Another resource would be to post the issues being experienced to the 'issues' section of the below GitHub page.

Additionally, I think that the following could also be used to create the desired result, the following is a document in the Tableau Community about using Python to create a nice smooted line over the bar chart.

Hope this helps!

Cheers,

Byrne, Patrick

1 of 1 people found this helpful
• ###### 2. Re: Using TabPy to make a Normal Curve

Thanks Patrick.

I will check these out in an hour or two and will share my results.

Thanks again.

Regards,

Pragyan Bezbaruah

• ###### 3. Re: Using TabPy to make a Normal Curve

No problem!

Happy to help!

Cheers,

Byrne, Patrick