Matplotlib Subplot

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]

x1=[10,20,30,40,50]
y1=[10,30,20,50,40]

x2=[100,200,300,400,500]
y3=[100,400,300,500,200]

mat.subplot(3,1,1)
mat.plot(x,y,marker="o",mec='k',mfc='r',ms=10,ls="solid",lw=5,c='b',label='Product1 ')
mat.plot(y1,x1,marker="o",mec='r',mfc='k',ms=10,ls="solid",lw=5,c='g',label='Product 2')
mat.xlabel("X-Product")
mat.xlabel("Y Product")
mat.title("Product")
mat.legend()
mat.subplot(3,1,2)

mat.plot(x1,y1,marker="o",mec='y',mfc='k',ms=10,ls="solid",lw=5,c='r',label='Sales')
mat.xlabel("X-Sales")
mat.xlabel("Y-Sales")
mat.title("Sales")
mat.legend()
mat.subplot(3,1,3)

mat.plot(x1,y1,marker="o",mec='y',mfc='k',ms=10,ls="solid",lw=5,c='r',label='Company')
mat.xlabel("X-Company")
mat.xlabel("Y-Company")
mat.title("Company")
mat.legend()
mat.show()

 

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback 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 *