# Perspective Box and Whisker Plot

**URL:** <https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034>\
**Category:** Ignition Exchange\
**Tags:** ignition80, perspective\
**Created:** [August 24, 2020, 7:01pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034 "2020-08-24T19:01:49Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 28, 2020, 8:00pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/21 "2020-08-28T20:00:04Z")

</div>

Pedant hat on:

> [@dkhayes117](#):
>
> #Result is 2.75, 5.5, and 8.25

Nope. 2.5, 5.0, 7.5 with eleven elements. Make it twelve elements and you'll match.

> [@dkhayes117](#):
>
> Quartile 1 will be the average of indexes 2 and 3

Well, not quite. In your case, 2.75 is closer to 3, so `myList[3]` should be weighted proportionally more: `q1 = (0.25*myList[2]+0.75*myList[3])`

`system.math.percentile()` appears to be getting this wrong.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 28, 2020, 8:17pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/22 "2020-08-28T20:17:08Z")

</div>

> [@pturmel](#):
>
> Nope. 2.5, 5.0, 7.5 with eleven elements. Make it twelve elements and you’ll match.

Yeah I rushed my response a little bit between pushing and testing a production project update, typing that post, and helping a friend write C code for an embedded system at the same time. 🙂

---

<div class="post-metadata">

**Author:** ![nickboratyn](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nickboratyn](https://forum.inductiveautomation.com/u/nickboratyn)\
**Post date:** [August 28, 2020, 8:57pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/23 "2020-08-28T20:57:30Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/4/34ddae9c7546640f41e2c6c1b595113631894051.png)  
I have a column of data as my input to the script transform, then I need to sort the column in ascending fashion. Finally, it seemed like the system.math.percentile could be something I could use but the script is not running yet.  
Edit: I should mention the first row in that column is a header

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 28, 2020, 8:59pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/24 "2020-08-28T20:59:59Z")

</div>

no need to sort the dataset before you call `system.math.percentile()` it will sort it internally.

---

<div class="post-metadata">

**Author:** ![nickboratyn](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nickboratyn](https://forum.inductiveautomation.com/u/nickboratyn)\
**Post date:** [August 28, 2020, 9:05pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/25 "2020-08-28T21:05:11Z")

</div>

alright, I got rid of the sorted = system.dataset.sort(value,Melter/TCs/TE20T1/Input/PV, True)  
so now I just have:  
q1 = system.math.percentile(value,25)  
return q1

But yet I still have an error. Is it because of the header on the column?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 28, 2020, 9:11pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/26 "2020-08-28T21:11:14Z")

</div>

You need to pass a list not a dataset into `percentile()`. You might could try, untested,

```auto
data = self.data
myColumn = 'Melter/TCs/TE20T01/Input/PV'
q1 = system.math.percentile(data.getColumnAsList(myColumn),25)

```

---

<div class="post-metadata">

**Author:** ![nickboratyn](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nickboratyn](https://forum.inductiveautomation.com/u/nickboratyn)\
**Post date:** [August 28, 2020, 9:45pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/27 "2020-08-28T21:45:19Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/11055f712510c215f35b03561ce403dbf813103a.png)  
I’ve got to be missing something simple here. I feel like I am close to getting it to work. Any input?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [August 28, 2020, 9:55pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/28 "2020-08-28T21:55:20Z")

</div>

you need to match the indentation of the def

```auto
def transform
    myColumn = 

```

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 28, 2020, 11:08pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/29 "2020-08-28T23:08:51Z")

</div>

Yep, indent your code to line up with the triple quotes

---

<div class="post-metadata">

**Author:** ![nickboratyn](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nickboratyn](https://forum.inductiveautomation.com/u/nickboratyn)\
**Post date:** [August 31, 2020, 1:54pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/30 "2020-08-31T13:54:10Z")

</div>

Hey guys, this is where I stand now. It seems to me maybe the “.getColumnAsList” function doesn’t work in ignition 8.0 but I could be wrong. My method here was to take my incoming column of data, delete the header and then perform the percentile function. I just assumed that the percentile function would not work if there was a header on the column.  
Edit: I am currently getting a parse error

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/2/6291a87261f5ee42f5d4841aba844ddebc9756a2.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 31, 2020, 4:57pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/31 "2020-08-31T16:57:01Z")

</div>

> [@nickboratyn](#):
>
> It seems to me maybe the “.getColumnAsList” function doesn’t work

It only takes one argument, the integer index of the column.

---

<div class="post-metadata">

**Author:** ![nickboratyn](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nickboratyn](https://forum.inductiveautomation.com/u/nickboratyn)\
**Post date:** [August 31, 2020, 6:01pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/32 "2020-08-31T18:01:57Z")

</div>

Yup, I found my mistake. Everything seems to be working as expected. Thanks!

---

<div class="post-metadata">

**Author:** ![nickboratyn](https://avatars.discourse-cdn.com/v4/letter/n/9d8465/32.png) [@nickboratyn](https://forum.inductiveautomation.com/u/nickboratyn)\
**Post date:** [September 23, 2020, 7:33pm UTC](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034/33 "2020-09-23T19:33:09Z")

</div>

Hey @ben.d.musson I know its been a while but consistently run into an issue. Whenever I bind values to the parameters on the embedded view in the example window, it seems to get over written by the original values. Would you know how to prevent that from happening?  
Thanks!

EDIT: Just to explain further on what I would want from this box and whisker plot, Id like to be able to place the chart onto a dashboard view and be able to bind the max, min, q1, q3 and median to each of my temperature tags

[Previous page](https://forum.inductiveautomation.com/t/perspective-box-and-whisker-plot/38034.md?page=1)
