mac饼图和环形图,并开启中文字体支持。
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = 'Arial Unicode MS' # 显示中文字体
x = [1, 5, 4, 3]
labels = ['a', 'b', 'c', 'd']
plt.subplot(121)
# 饼图
plt.pie(x, labels=labels)
plt.title("饼图")
plt.subplot(122)
# 环形图
plt.pie(x, labels=labels, wedgeprops={ 'width': 0.5},
colors=['#ff9999','#66b3ff','#99ff99','#ffcc99'],
autopct='%1.2f%%')
plt.title("环形图")
plt.show()
