Site icon DataFlair

Python Matplotlib Program for Scatter Plot

Machine Learning courses with 110+ Real-time projects Start Now!!

Program 1

import matplotlib.pyplot as mat
x=[0,1,2,3,4,5]
y=[i*2 for i in x]
y1=[i**2 for i in x]
y2=[i**3 for i in x]
mat.scatter(x,y,marker='s',label="Sales",s=20,linewidth=4,color='red',alpha=1)
mat.scatter(x,y1,marker='o',label="Product",s=20,linewidth=4,color='blue',alpha=1)
mat.scatter(x,y2,marker='o',label="Company",s=20,linewidth=4,color='yellow',alpha=1)
mat.legend()
mat.show()

 

Exit mobile version