xlabel() , ylabel() for specifying x and y axis name.
title() — used to specify plot name
grid() — Given True as parameter turns on the grid
show() — shows the plot
…………………………………………………………………………………
Delta function
from matplotlib import pyplot as pltplt.style.use('ggplot')xval = [x for x in range(-100,100)]yval=[]for t in range(-100,100): if t==0: yval.append(1) else: yval.append(0)plt.plot(xval,yval,label="delta function")plt.xlabel("time")plt.ylabel("Amplitude")plt.grid(True)plt.legend()plt.show()
Press enter or click to view image in full size
Delta function
Step function
from matplotlib import pyplot as pltplt.style.use('ggplot')x_val = [x for x in range(-100,100)]y_val =[]for x in x_val: if x>=0: y_val.append(1) else: y_val.append(0)plt.plot(x_val,y_val,color='g',label="Step signal")plt.legend()plt.title("step signal")plt.xlabel('time')plt.ylabel('amp')plt.show()
Press enter or click to view image in full size
Step Function
Signum Function
from matplotlib import pyplot as pltplt.style.use('ggplot')x_val = [x for x in range(-50,50)]y_val=[]for x in x_val: if x>=0: y_val.append(1) else: y_val.append(-1)plt.stem(x_val,y_val,label="signum function")plt.legend()plt.title("Signum Function")plt.xlabel("Time")plt.ylabel("Amplitude")plt.show()
Press enter or click to view image in full size
Signum Function
Sine Function
from matplotlib import pyplot as pltimport numpy as npplt.style.use('ggplot')x_val = np.arange(-np.pi,np.pi,0.5)y_val = [np.sin(x) for x in x_val]plt.plot(x_val,y_val,color='g',label="sine wave")plt.legend()plt.title("Sine wave")plt.xlabel("Time")plt.ylabel("Amplitude")plt.show()
Press enter or click to view image in full size
Sine wave
Cos Function
from matplotlib import pyplot as pltimport numpy as npplt.style.use('ggplot')x_val = np.arange(0,4*np.pi,0.5)y_val = [np.cos(i) for i in x_val]plt.plot(x_val,y_val,label="cos wave")plt.legend()plt.title("Cos wave")plt.xlabel("Time")plt.ylabel("Amplitude")plt.grid(True)plt.tight_layout()plt.show()
Press enter or click to view image in full size
cosine
Ramp Function
from matplotlib import pyplot as pltplt.style.use('ggplot')x_val = [x for x in range(-10,100)]y_val=[]t=0for x in x_val: if x>=0: y_val.append(t*1) t+=1 else: y_val.append(0)plt.plot(x_val,y_val,label="Ramp signal")plt.legend()plt.xlabel("Amplitude")plt.ylabel("Time")plt.title("Ramp signal")plt.show()