Example : 4 Line Plot
from matplotlib import pyplot as plt from matplotlib import style style.use('ggplot') x = [5,8,10] y = [12,16,6] x2 = [6,9,11] y2 = [6,15,7] plt.plot(x,y,'g',label='line one', linewidth=5) plt.plot(x2,y2,'c',label='line two',linewidth=5) plt.title('Example Line Plot') plt.ylabel('Y axis') plt.xlabel('X axis') plt.legend() plt.grid(True,color='r') plt.show()
Example : 5 Line Plot
# importing matplotlib module from matplotlib import pyplot as plt # x-axis values x = [5, 2, 9, 4, 7] # Y-axis values y = [10, 5, 8, 4, 2] # Function to plot plt.plot(x,y,'b',label='Line 1',linewidth=5) #giving title, x axis, y axis plt.title('Example Line Plot') plt.ylabel('Y axis') plt.xlabel('X axis') plt.legend() plt.grid(True,color='r') # function to show the plot plt.show()
Example : 6 Line Plot
from matplotlib import pyplot as plt import numpy as np x = np.arange(1,11) y = np.random.random(10) print(x) print(y) plt.plot(x,y) plt.show()
Output:
[ 1 2 3 4 5 6 7 8 9 10]
[0.75769183 0.15878421 0.61943324 0.31750067 0.9580151 0.17189032
0.65672839 0.18876268 0.26326319 0.22721435]
>>>