0.4 Plotting Signals

Plot the Signal

Let's display the signal. To make calling these multiple times easier, let's write a function. Further, to be able to save the results, let's add a conditional statement to allow saving the result.

def plot_signal(x, xaxis_label=None, yaxis_label=None, save=None):
    plt.plot(x)
    plt.xlabel(xaxis_label)
    plt.ylabel(yaxis_label)
    
    if save:
        plt.savefig(save + '.pdf', format='pdf')
    
    return

plot_signal(s, xaxis_label=r'$n$', yaxis_label=r'$s[n]$', save='input')

Feel free to add more functionality to the plotting function. Possible explorations are to check to add legends , titles, linestyles, linewidths, plot colours. See Matplotlib documentation for more.

Last updated

Was this helpful?