def plot_graph():
lables = '男生比例','女生比例','其他'
sizes = get_friends_rate()
plt.pie(sizes, lables, autopct='%.3f%%', shadow=False, startangle=90)
plt.axis('equal')
plt.show()
plot_graph()
def get_friends_rate() returns
return [float(male)/total 100, float(female)/total 100, float(other)/total * 100]
appears when running mistake:
The following source code is used:
Just pass in the labels using the labels parameter. Python2.7 is used to write it here. Since it is in Chinese, there will be a problem that it cannot be displayed.