import numpy as np import matplotlib.pyplot as plt tot_time = 200 time1 = 30 time2 = 90 time3 = 150 depth0 = 0 depth1 = 3 depth2 = 5 depth_des = np.arange(tot_time) depth_des = np.piecewise(depth_des, [depth_des < time1, (depth_des >= time1) & (depth_des < time2), (depth_des >= time2) & (depth_des < time3), depth_des >= time3], [depth0, depth1, depth2, depth0]) plt.plot(depth_des)