Site icon DataFlair

Cmap and ColorBar in Scatter Plot using Matplotlib

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=[0,1,4,9,16,25]
#mycolor=['red','blue','green','black','blue','yellow']
mycolor=[10,20,30,40,50,60]
mysize=[100,250,150,200,300,250]
mat.scatter(x,y,c=mycolor,s=mysize,cmap="Accent")
mat.colorbar()
mat.show()

 

Exit mobile version