current position:Home>Drawing pie chart in Python

Drawing pie chart in Python

2022-07-24 15:47:43I am a little rice

# -*- coding: utf-8 -*-
import numpy as np  
import matplotlib.mlab as mlab  
import matplotlib.pyplot as plt  
labels=[" waters ", " Barren land ", " Low vegetation ", " tree ", " Architecture ", " playing field ", " road "]
colors  = ["#126bae","#b7ae8f","#8cc269","#41b349","#fa7e23","#feba07"]
X=dataSet.iloc[0][2:]  
 
fig = plt.figure()
plt.title(" Geological proportion before earthquake ")
plt.pie(X,labels=labels,colors=colors, autopct='%1.2f%%',pctdistance=0.8) # Draw a pie chart ( data , The label corresponding to the data , Keep two decimal places for the percentage )
  
plt.savefig("start.png", dpi=300)
plt.show();

X The numerical :
 Insert picture description here

 Please add a picture description

# -*- coding: utf-8 -*-
import numpy as np  
import matplotlib.mlab as mlab  
import matplotlib.pyplot as plt  
labels=[" waters ", " Barren land ", " Low vegetation ", " tree ", " Architecture ", " playing field ", " road "]
colors  = ["#126bae","#b7ae8f","#8cc269","#41b349","#fa7e23","#feba07"]
X=dataSet.iloc[3][2:]  
 
fig = plt.figure()
plt.pie(X,labels=labels, colors=colors, autopct='%1.2f%%', pctdistance=0.8) # Draw a pie chart ( data , The label corresponding to the data , Keep two decimal places for the percentage )
plt.title(" Geological proportion after earthquake ")
  
plt.savefig("end.png", dpi=300)
plt.show();

 Please add a picture description

copyright notice
author[I am a little rice],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/205/202207241543108911.html

Random recommended