matplotlib之饼状图

import matplotlib.pyplot as plt


labels = 'A', 'B', 'C', 'D'
fracs = [35, 20, 45, 10]

plt.pie(x=fracs, labels=labels)
plt.show()

圆形饼图

import matplotlib.pyplot as plt


labels = 'A', 'B', 'C', 'D'
fracs = [35, 20, 45, 10]

plt.axes(aspect=1)
plt.pie(x=fracs, labels=labels)
plt.show()

比例显示

import matplotlib.pyplot as plt


labels = 'A', 'B', 'C', 'D'
fracs = [35, 20, 45, 10]

plt.axes(aspect=1)
plt.pie(x=fracs, labels=labels, autopct='%.0f%%')
plt.show()

突出显示

import matplotlib.pyplot as plt


labels = 'A', 'B', 'C', 'D'
fracs = [35, 20, 45, 10]
explode = [0, 0.05, 0.08, 0]

plt.axes(aspect=1)
plt.pie(x=fracs, labels=labels, autopct='%.0f%%', explode=explode)
plt.show()

添加阴影

import matplotlib.pyplot as plt


labels = 'A', 'B', 'C', 'D'
fracs = [35, 20, 45, 10]
explode = [0, 0.05, 0.08, 0]

plt.axes(aspect=1)
plt.pie(x=fracs, labels=labels, autopct='%.0f%%', explode=explode, shadow=True)
plt.show()

猜你喜欢

转载自blog.csdn.net/Mr_blueD/article/details/81236632