import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
sales = [38, 32, 30]
products = ['产品A', '产品B', '产品C']
persons = ['李敏', '王鹏', '张晶']
labels = [f'{p}\n({name})' for p, name in zip(products, persons)]
plt.figure(figsize=(8, 6))
patches, texts, autotexts = plt.pie(
sales,
labels=labels,
autopct='%1.1f%%',
startangle=90,
textprops={'fontsize': 12},
colors=['#ff9999','#66b3ff','#99ff99']
)
for autotext in autotexts:
autotext.set_color('black')
autotext.set_fontsize(12)
plt.title('季度产品销售占比分布', fontsize=16, pad=20)
plt.legend(
title="产品负责人",
loc="upper right",
bbox_to_anchor=(1.1, 1),
labels=[f'{p} - {n}' for p, n in zip(products, persons)]
)
plt.axis('equal')
plt.show()