0% found this document useful (0 votes)
9 views11 pages

Python Matplotlib Visualization Examples

The document contains a series of Python programs utilizing Matplotlib for data visualization. It includes examples of line plots, bar charts, pie charts, and scatter plots to represent various datasets such as flu rates, programming language popularity, and sales figures. Each program is designed to demonstrate different plotting techniques and customization options available in Matplotlib.

Uploaded by

sarasaranya916
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)
9 views11 pages

Python Matplotlib Visualization Examples

The document contains a series of Python programs utilizing Matplotlib for data visualization. It includes examples of line plots, bar charts, pie charts, and scatter plots to represent various datasets such as flu rates, programming language popularity, and sales figures. Each program is designed to demonstrate different plotting techniques and customization options available in Matplotlib.

Uploaded by

sarasaranya916
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

PYTHON MATPLOTLIB PROGRAMS

1.
import [Link] as plt
import numpy as np
y1=[Link]([1,4,7,9])
y2=[Link]([3,6,2,1])
x=[Link](["2006","2007","2008","2009"])
[Link]("YEAR")
[Link]("AFFECTED BY FLU RATE")
[Link]("RATE VS YEAR")
[Link](x,y1,linewidth=9,ls="dotted",c="red",label="KER
ALA")
[Link](x,y2,linewidth=9,ls="dotted",c="green",label="TA
MILNADU")
[Link]()
[Link]()
2.
import [Link] as plt
x=["java","python","PHP","javascript","c","c++"]
y1=[22.2,17.6,8.8,8,7.7,6.7]
c=["red","yellow","cyan","green","blue","purple"]
[Link](x,y1,color=c)
for index,value in enumerate(y1):
[Link](value+0.3,index,str(value),va="center")
[Link]("POPULARITY")
[Link]("PROGRAMMING LANGUAGES")
[Link]("Popularity of different programming
languages")
[Link]()
[Link]()

3.
3.
import [Link] as plt
import numpy as np
i = [Link](6)+0.5
v1=[2,4,8,5,7,6]
v2=[4,2,3,4,2,6]
v3=[6,4,7,4,7,8]
v4=[8,2,6,4,8,6]
v5=[10,2,4,3,3,2]
bw = 0.3
[Link]('IA-1 MARK COMPARISON BETWEEN
DEPARTMENTS',fontsize=20)
[Link](i,v1,bw,color='b')
[Link](i+bw,v2,bw,color='g')
[Link](i+2*bw,v3,bw,color='r')
[Link](i+3*bw,v4,bw,color="y")
[Link](i+4*bw,v2,bw,color="c")
[Link](i+5*bw,v2,bw,color="w")
[Link](i+bw,['A','B','C','D','E','F'])
[Link]()

4.
import [Link] as plt
labels = ['android','ios','windows','others']
popularity = [10,30,45,15]
colors = ['yellow','green','red','blue']
[Link](popularity,labels=labels,colors=colors)
[Link]("POPULARITY OF MOBILE PHONE USAGE")
[Link]('equal')
[Link]()

5.
import [Link] as plt
import pandas as pd
x=pd.read_csv("[Link]")
c=x["country"]
gm=x["gold_medal"]
[Link](gm,labels=c)
[Link]("GOLD MEDAL ACHIVEMENTS IN 2016 SUMMER
OLYMPICS")
[Link]()
6.
import numpy as np
import [Link] as plt
x=[Link](10)
math_marks=[88,92,80,89,100,80,60,100,80,34]
science_marks=[35,79,79,48,100,88,32,45,20,30]
[Link](x,science_marks,color="green",label="SCIENC
E MARKS")
[Link](x,math_marks,color="red",label="MATHS
MARKS")
[Link]("MATH VS SCIENCE MARKS")
[Link]("Mathematics marks")
[Link]("Science marks")
[Link]()
[Link]()

7.
import [Link] as plt
import numpy as np
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
face_cream_sales = [200, 250, 300, 350, 400, 450]
face_wash_sales = [150, 200, 250, 300, 350, 400]
fig, (ax1, ax2) = [Link](1, 2, figsize=(12, 6))
[Link](months, face_cream_sales, color='pink')
ax1.set_title('Face Cream Sales')
ax1.set_xlabel('Months')
ax1.set_ylabel('Sales (Units)')
[Link](True)
[Link](months, face_wash_sales, color='lightblue')
ax2.set_title('Face Wash Sales')
ax2.set_xlabel('Months')
ax2.set_ylabel('Sales (Units)')
[Link](True)
[Link]()

You might also like