I have 3 process parameters that independently cycle between zero and some peak value, as shown on this filled line time-series plot: enter image description here

Although not a direct control variable, the 'health' of the system can be gauged by the consistency of relative 'stagger' (or difference) between these three parameters at any single point in time. A-B, B-C, C-A.

I am struggling to find an effective way to represent these relative stagger values - on the same timeline. A simple plot of e.g. A - B cycles positive to negative but isn't very intuitive. Ideally I'd like to represent all three relative differences on one discernible plot.


You could compare the relative values over time quite easily with a "stacked" graph, where each of the processes is a layer in the stack. In Pandas' plotting, it is referred to as an area plot.

Here is an example with some dummy data:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

p1, p2, p3 = np.random.random(100), np.random.random(100), np.random.random(100)

df = pd.DataFrame([p1, p2, p3]).T
# output
#              0         1         2
#    0  0.542490  0.099974  0.831589
#    1  0.988922  0.035026  0.752813

df.plot(kind="area", stacked=True); plt.show()

stacked/area plot

I think this might allow you to see the relative swings in each of the processes quite clearly - you could also shift the slightly to be in phase, which will make things easier.

| improve this answer | |
  • $\begingroup$ Perfect - just checked Plotly Filled Area and I think it will do the job - even representing when the difference switches positive to negative. Many thanks :) $\endgroup$ – MarkMyWords Mar 31 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.