餅圖
- 設置顏色
- 設置字體顏色
- 設置說明文字
%matplotlib inline
import matplotlib.pyplot as plt
m = 51212
f = 40742
m_perc = m/(m+f)
f_perc = f/(m+f)
colors = ['navy','lightcoral']
labels = ["Male","Female"]
plt.figure(figsize=(8,8))
paches,texts,autotexts = plt.pie([m_perc, f_perc], labels = labels,
autopct = '%1.1f%%', explode = [0,0.05], colors = colors)
for text in texts+autotexts:
text.set_fontsize(20)
for text in autotexts:
text.set_color('white')