diff --git a/tcontrol/plot_utility.py b/tcontrol/plot_utility.py index a6dcf6e68ab261f3123eb0ec4e5b9eb18379885a..d11b8d5d4e7aaa960831fe6aa6c3cab69ac1f6a2 100644 --- a/tcontrol/plot_utility.py +++ b/tcontrol/plot_utility.py @@ -84,6 +84,11 @@ class AttachedCursor(widgets.Cursor): def plot_response_curve(y, t, title, continuous=True): + if not isinstance(y, np.ndarray): + y = np.array(y) + if len(y.shape)==2 and y.shape[0]>1: + # Multi-output system + return plot_responses_curve(y, t, title, continuous) fig = plt.figure() axes = fig.add_axes([0.1, 0.1, 0.8, 0.8]) axes.set_xlabel('t/s') @@ -98,6 +103,25 @@ def plot_response_curve(y, t, title, continuous=True): axes.grid() plt.show() +def plot_responses_curve(y, t, title, continuous=True): + # TODO: no access of output name. + # It should be better if output name is set as ylabel + fig = plt.figure() + fig.suptitle(title) + p = y.shape[0] + for i in range(p): + ax = plt.subplot(p, 1, i+1) + ax.set_xlabel('t/s') + ax.set_ylabel('Amplitude') + ax.axvline(x=0, color='black') + ax.axhline(y=0, color='black') + if continuous: + ax.plot(t, y[i]) + else: + ax.step(t, y[i], where='post') + ax.grid() + plt.show() + def plot_rlocus(kwargs, roots, system): fig, ax = plt.subplots()