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()