def plot_loads(ti, tf, loads, max_y):
"""
plot load curves
\param ti : init t
\param tf : final t
\param loads : list of load curve lists
loads = [[ load1], [load2], ...]
\param max_y : vertical limit."""
#imports
from matplotlib import pyplot as plt
import numpy as np
import random
ys_array = []
for item in loads:
ys_array.append(item)
y = np.row_stack(ys_array)
x = np.arange(ti, tf)
y_stack = np.cumsum(y, axis=0)
fig = plt.figure(random.randint(1,1000))
#plot frame positioning
ax1 = fig.add_subplot(211)
#plot maximum load
ax1.fill_between(x, 0, max_y, alpha=0.1, facecolor = 'black')
#
for i, item in enumerate(loads):
if i == 0:
ax1.fill_between( x, 0, y_stack[0,:], facecolor = random.choice(['g', 'r', 'c', 'm', 'y', 'k']))
else:
ax1.fill_between( x, y_stack[i-1,:], y_stack[i,:], facecolor =random.choice(['g', 'r', 'c', 'm', 'y', 'k']))
plt.show()