Why does the end location of my line not represent the average of the data?

22 Views Asked by At

I have a data viz that encodes ordinal data as a line of a specific angle. All the lines are chained together to create a path.

Here is an example enter image description here

where I encode Amazon ratings in the range of $[1..5]$. You can see that in the first 2 examples the end node of the path is located at the angle from the focal point that represents the average of the data. This is what I want!

However, in the last example on the bottom, this is not the case anymore. The real average would be $3.25$ but the actual end node of the path is located around the angle representing $3.5$.

My question is, why this is the case and whether or not there is a solution to this problem. I would like to add an average line and axis (like the arc in the sample case) to add a cue for the user. But if the chart does not represent correct values I cannot do that.

1

There are 1 best solutions below

1
On

Let’s use standard radian measure for the angles (not your 0-5) and suppose each segment has length 1. If the angles are $t_1, t_2, \ldots, t_n$ for the $n$ ratings, and the path starts at $(0,0)$, then the endpoint $(x,y)$ has $$x=\cos t_1+\cos t_2+\cdots +\cos t_n$$ and $$y=\sin t_1+\sin t_2+\cdots +\sin t_n$$ so the ending angle $t$ satisfies $$\tan t =\frac{\sin t_1+\sin t_2+\cdots +\sin t_n}{\cos t_1+\cos t_2+\cdots +\cos t_n}$$ so $$t =\boxed{\arctan \frac{\sin t_1+\sin t_2+\cdots +\sin t_n}{\cos t_1+\cos t_2+\cdots +\cos t_n}}$$ But just averaging the angles instead would give $$t’ = \boxed{\frac{t_1 +t_2+\cdots+ t_n}{n}}$$ These are not the same thing.