Drawing of Matplotlib series-pyplot pie chart
Pyplot use Plt.pie () to draw a pie chart
Import Matplotlib.pyplot as plt
labels = ' frogs ', ' hogs ', ' Dogs ', ' Logs '
sizes = [15,30,45,10]
explode = ( 0,0.1,0,0) #0 1 means to highlight the Hogs piece
plt.pie (sizes,explode=explode,labels=labels,autopct= '%1.1f%% ', Shadow=false, startangle=90)
#startangle表示饼图的起始角度
plt.show ()
Run Result:
So how do you make the pie chart appear as a pie chart with a long width equal to just one line of code?
Import Matplotlib.pyplot as plt
labels = ' frogs ', ' hogs ', ' Dogs ', ' Logs '
sizes = [15,30,45,10]
explode = ( 0,0.1,0,0) #0 1 means to highlight the Hogs piece
plt.pie (sizes,explode=explode,labels=labels,autopct= '%1.1f%% ', Shadow=false, startangle=90) #startangle表示饼图的起始角度
plt.axis (' equal ') #加入这行代码即可.
Plt.show ()
Run Result:
Reference: Beijing Polytechnic University song Tian Teachers teaching video