Pie Chart , Donut Plot, Area plot

Pie Chart :
import matplotlib.pyplot as plt
a= ["apple","banana","mango"]
b = [30,10,80]

fig = plt.figure(figsize=(10,5))

plt.pie(b,labels=a, autopct = "%1.1f%%", shadow=True, startangle = 90)

plt. show()
Customizing Pie Chart :
import matplotlib.pyplot as plt
a= ["apple","banana","mango"]
b = [30,10,80]

fig = plt.figure(figsize=(10,5))

plt.pie(b,labels=a,autopct = "%1.1f%%" , shadow=True, startangle = 90, explode= (0.1,0.1,0))

plt. show()
Pie Chart Without Shadow :
import matplotlib.pyplot as plt
a= ["apple","banana","mango"]
b = [30,10,80]

fig = plt.figure(figsize=(10,5))

plt.pie(b,labels=a,autopct = "%1.1f%%", shadow=False, startangle = 90,     explode= (0.1,0.1,0))

plt. show()
Donut Plot :
import matplotlib.pyplot as plt
name= ["kanchan" ,"kariahma","kajal",]
marks = [80,85,90]
center=[10]
fig = plt. figure(figsize=(10,5))

plt. pie(marks,labels=name,radius=0.8)
plt.pie(center,radius=0.4)
 plt. show()
Area plot :
import matplotlib.pyplot as plt
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
b = [4,2,5,11,7,12,17,9,3,6,8,1,14,21,10]
fig = plt.figure(figsize=(10,5))

plt.stackplot(a,b,color = "red",alpha = 0.7,edgecolor="black",linestyle="--",linewidth=2.7)

plt.legend(["Area"],loc="best")
plt.grid(True)
plt.xlabel("X axis")
plt.ylabel("Y axis")
plt.show()
Merge Area Chart With The Line Chart :
import matplotlib.pyplot as plt
a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
b = [4,2,5,11,7,12,17,9,3,6,8,1,14,21,10]
fig = plt.figure(figsize=(10,5))

plt.stackplot(a,b,color = "red",alpha = 0.7,edgecolor="black",linestyle="--",linewidth=2.7)

plt.legend(["Area"],loc="best")
plt.grid(True)
plt.xlabel("X axis")
plt.ylabel("Y axis")
# Merge area chart with line chart
plt.plot(a,b,color="green")
plt. show()

Comments

Popular posts from this blog

Python Tokens