Matplotlib Program for Legend Function

Machine Learning courses with 100+ 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]
y1=[0,10,20,30,40,50]
y2=[0,20,10,40,30,50]
#mat.plot(x,y,x,y1)
# mat.legend(['Sales','Product'])
mat.plot(x,y,label="Product",marker=".",mfc='r',mec='k')
mat.plot(x,y1,label="Sales",marker="*",mfc='y',mec='k')
mat.plot(x,y2,label="Company",marker=".",mfc='c',mec='k')
mat.legend(loc=2,facecolor='cyan',edgecolor='red',framealpha=0.5,shadow=True,fancybox=True)
mat.show()

 

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

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