Matplotlib Colormaps

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

Program 1

import matplotlib.pyplot as plt
import numpy as np
x = np.array([5,7,8,7,2,17,2,9,4,11,12,9,6])
y = np.array([99,86,87,88,111,86,103,87,94,78,77,85,86])
colors = np.array([10,20,25,35,50,60,75,80,90,100,110,120,130])
plt.scatter(x,y,cmap='BuPu',c=colors)
plt.colorbar()
plt.xlabel("Car Age")
plt.ylabel("Milage")
plt.legend()
plt.show()

#x1 = np.array([2,2,8,1,15,8,12,9,7,3,11,4,7,14,12])
# y1 = np.array([100,105,84,105,90,99,90,95,94,100,79,112,91,80,85])
# colors = np.array(["red","green","blue","yellow","pink","black","orange","purple","beige","brown","gray","cyan","magenta"])
# size=[25,37,48,17,42,37,22,89,14,11,12,19,16]
# plt.scatter(x,y,marker='o',label="Car Day 1" ,s=size,c=colors)
# #plt.scatter(x1,y1,marker='o',label="Car Day 2",s=70)

 

 

Your opinion matters
Please write your valuable feedback about DataFlair on Google

courses
Image

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

Your email address will not be published. Required fields are marked *