# "Grouped Bar and Line Chart in Perspective for Energy Monitoring"

**URL:** <https://forum.inductiveautomation.com/t/grouped-bar-and-line-chart-in-perspective-for-energy-monitoring/107957>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [June 30, 2025, 9:49pm UTC](https://forum.inductiveautomation.com/t/grouped-bar-and-line-chart-in-perspective-for-energy-monitoring/107957 "2025-06-30T21:49:35Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [September 19, 2025, 3:44pm UTC](https://forum.inductiveautomation.com/t/grouped-bar-and-line-chart-in-perspective-for-energy-monitoring/107957/5 "2025-09-19T15:44:50Z")

</div>

Yes, though I didn't create it, and don't recall where/how I found it (might have been from [this post](https://forum.inductiveautomation.com/t/inventory-prediction-manager/93439/11)):

```python
def linreg(X, Y):
    if len(X) != len(Y): raise ValueError, 'unequal length'
    N = len(X)
    Sx = Sy = Sxx = Syy = Sxy = 0.0
    for x, y in map(None, X, Y):
        Sx = Sx + x
        Sy = Sy + y
        Sxx = Sxx + x*x
        Syy = Syy + y*y
        Sxy = Sxy + x*y
    det = Sxx * N - Sx * Sx
    a, b = (Sxy * N - Sy * Sx)/det, (Sxx * Sy - Sx * Sxy)/det
    meanerror = residual = float(0.0)
    for x, y in map(None, X, Y):
        meanerror = meanerror + (y - Sy/N)**2
        residual = residual + (y - a * x - b)**2
    RR = 1 - residual/meanerror
    ss = residual / (N-2)
    Var_a, Var_b = ss * N / det, ss * Sxx / det
    return a, b, RR

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/grouped-bar-and-line-chart-in-perspective-for-energy-monitoring/107957)._
