Calculate are - varea_stack

@Zana

Numpy implements the trapezoidal rule via the trapz method, which will give you the area under a curve.

The area under each incremental segment can be calculated as follows

np.trapz(df, axis=0)

To get the area of each (cumulatively) stacked region w.r.t. the origin, both of the following will give the same answer

np.trapz(df, axis=0).cumsum()

or

np.trapz(df.cumsum(axis=1), axis=0)

If you need to do this in JavaScript in a callback, for example, without the benefit of numpy or Python callbacks, you could compute manually easily as the trapezoidal rule is simple for uniformly spaced data.

3 Likes