Skip to content

Instantly share code, notes, and snippets.

@sparkydogX
Created November 21, 2018 13:09
Show Gist options
  • Save sparkydogX/26e5b475f9aa382525bb660fdf8cb75f to your computer and use it in GitHub Desktop.
Save sparkydogX/26e5b475f9aa382525bb660fdf8cb75f to your computer and use it in GitHub Desktop.
使用matplot绘制饼状图
import itertools
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['font.sans-serif']=['Tahoma', 'DejaVu Sans','Lucida Grande', 'Verdana']
if __name__ == '__main__':
plt.figure(figsize=(6,9))
labels = ['stand', 'walk', 'run']
sizes = [3322,13331,277]
explode = (0.02,0.02,0.02)
patches,text1,text2 = plt.pie(sizes,
explode=explode,
labels=labels,
#colors=colors,
labeldistance = 1.2,
autopct = '%3.2f%%',
shadow = False,
startangle =90,
pctdistance = 0.6)
plt.axis('equal')
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment