制作饼图
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
from typing import List
class Chart:
set_style = "whitegrid"
font = FontProperties(fname="simhei.ttf")
def pie(self, sizes: List[int], labels: List[str], title="title"):
"""
饼图
:param sizes: 数据
:param labels: 标签
:param title: 图表描述
"""
sns.set_style(self.set_style)
patches,l_text,p_text = plt.pie(sizes, labels=labels, autopct='%1.2f%%')
plt.title(title,fontproperties=self.font)
for l in l_text:
l.set_fontproperties(self.font)
plt.legend(prop=self.font)
plt.show()