0% found this document useful (0 votes)
2 views5 pages

Examples

The document contains multiple examples of using the matplotlib library in Python for data visualization. It includes various types of plots such as line charts, bar charts, histograms, and horizontal bar charts, along with customization options like titles, labels, and legends. Additionally, it demonstrates the use of pandas for handling data and plotting from DataFrames.

Uploaded by

manishmcamba2013
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Examples

The document contains multiple examples of using the matplotlib library in Python for data visualization. It includes various types of plots such as line charts, bar charts, histograms, and horizontal bar charts, along with customization options like titles, labels, and legends. Additionally, it demonstrates the use of pandas for handling data and plotting from DataFrames.

Uploaded by

manishmcamba2013
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Example-1

import [Link] as plt


roll=[1,2,3,4,5]
sub1=[99,67,33,21,87]
[Link](221)
[Link]("LINE CHART")
[Link](roll,sub1)
sub2=[56,78,45,36,78]
[Link](222)
[Link]("BAR CHART")
[Link](roll,sub2)
[Link](223)
[Link]("HISTOGRAM")
sub3=[45,67,89,23,24,23,45,67,89,21,22,20,11,5,99,56,34,34,23,27,32,74,76]
[Link](sub3)
[Link]()

Example-2
import [Link] as plt
week=[1,2,3,4]
s1=[23,24,43,10]
s2=[9,48,20,39]
s3=[49,35,6,45]
[Link](figsize=(8,6))
[Link](week,s1,color='r',marker=".",markersize="8",label='TEST-1')
[Link](week,s2,color='g',marker="o",markersize="8",label='TEST-2')
[Link](week,s3,color='b',marker="*",markersize="8",label='TEST-3')
[Link]("NAME OF THE STUDENT")
[Link]("MARKS")
[Link]("MARKS IN TESTS")
[Link](True)
[Link](loc='upper center')
student=['RAJ','MOHAN','JAY','SANJAY']
[Link](week,student)
for i in range(len(week)):
[Link](week[i],s1[i],s=s1[i],fontsize=15,rotation=45,color='b')
[Link](week[i],s2[i],s=s2[i],fontsize=15,rotation=45,color='g')
[Link](week[i],s3[i],s=s3[i],fontsize=15,rotation=45,color='r')
[Link]("C:[Link]",dpi=400,facecolor='y',edgecolor='r')
[Link]()
Example-3
import [Link] as plt
x=[2,4,6,8,10]
y=[3,6,7,18,11]
[Link](x,y,'r*--',lw=2.5,ms=25,mfc='g',mec='r')
[Link]('X')
[Link]('Y')
[Link]('X vs Y')
[Link](range(0,15,3))
[Link](range(0,20,3))
[Link]()
[Link]()

Example-4
import [Link] as plt
student=['RAJ','MOHAN','JAY','SANJAY']
s1=[23,24,43,10]
s2=[9,48,20,39]
s3=[49,35,6,45]
[Link](figsize=(12,6))
x=[0,1,2,3]
[Link](x,s1,color='r',label='TEST-1',width=0.2)
y=[]
for i in range(len(x)): [Link](x[i]+0.2)
[Link](y,s2,color='g',label='TEST-2',width=0.2)
z=[]
for i in range(len(x)):[Link](x[i]-0.2)
[Link](z,s3,color='b',label='TEST-3',width=0.2)
[Link]("NAME OF THE STUDENT")
[Link]("MARKS")
[Link]("MARKS IN TESTS")
[Link](True)
[Link](x,student)
[Link](loc='upper right')
for i in range(len(student)):
[Link](x[i],s1[i],s=s1[i],fontsize=15,color='b')
[Link](y[i],s2[i],s=s2[i],fontsize=15,color='g')
[Link](z[i],s3[i],s=s3[i],fontsize=15,color='r')
[Link]("C:\\Users\\manis\\OneDrive\\Desktop\\[Link]",
dpi=400,facecolor='y',edgecolor='r')
[Link]()

Example-5
import [Link] as plt
student=['RAJ','MOHAN','JAY','SANJAY']
s1=[23,24,43,10]
s2=[9,48,20,39]
[Link](figsize=(12,6))
[Link](s1,width=0.2,color='r',label='TEST-1')
[Link](s2,width=0.2,color='g',label='TEST-2')
[Link]("NAME OF THE STUDENT")
[Link]("MARKS")
[Link]("MARKS IN TESTS")
[Link](True)
#[Link](x,student)
[Link](loc='upper right')
[Link]()

Example-6
import pandas as pd
import [Link] as plt
d={'SUB1':[78,90,67,45],'SUB2':[90,80,23,72],'SUB3':[65,47,89,90],
'SUB4':[67,97,87,33]}

df=[Link](d,index=['RAJ','JAY','SANJAY','BIJAY'])
print(df)

[Link](kind='bar')

[Link]()
Example-7

import pandas as pd
import [Link] as plt
d={'SUB1':[78,90,67],'SUB2':[90,80,23],'SUB3':[65,47,89]}
df=[Link](d,index=['RAJ','JAY','SANJAY'])
print(df)
barwidth=0.25
v=len([Link])
r1=range(v)
r2=[x+barwidth for x in r1]
r3=[x+barwidth for x in r2]
[Link](r1,df['SUB1'],width=0.25,color='red',edgecolor='white',label='SUB1')
[Link](r2,df['SUB2'],width=0.25,color='yellow',edgecolor='white',label='SUB2')
[Link](r3,df['SUB2'],width=0.25,color='green',edgecolor='white',label='SUB2')
[Link](r2,[Link])
[Link]("Name of the students")
[Link]("Marks of the students")
[Link]("Marks of Students")
[Link]()
#[Link](subplots=True,xlabel="Name")
[Link]()

Example-8
import [Link] as plt
[Link]([5,15,25,35,45,55],bins=[0,10,20,20,40,50,60],weights=[20,10,45,33,6,8],
edgecolor="red",facecolor='y')
[Link]("HISTOGRAM")
[Link]()

Example-9
import [Link] as plt
[Link]([5,15,25,35,45,55],bins=[0,10,20,20,40,50,60],weights=[20,10,45,33,6,8],
edgecolor="red",facecolor='y')
[Link]("HISTOGRAM")
[Link]()

Example-10

import [Link] as plt


import pandas as pd
df=pd.read_csv("C:\\Users\\manis\\OneDrive\\Desktop\\workshop sep-
2024\\enrolment_age_2012_13.csv")
print(df)
[Link](kind='line',x='state_name',y='class_1_girls')
[Link]()

You might also like