資料視覺化之matplotlib實戰:plt.pie()函式 繪製餅狀圖

超級大洋蔥806發表於2020-10-03
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

# 防止亂碼
mpl.rcParams["font.sans-serif"] = ["SimHei"]
mpl.rcParams["axes.unicode_minus"] = False

kinds = "簡易箱","保溫箱","行李箱","密封箱"

colors = ["#e41a1c","#377eb8","#4daf4a","#984ea3"]

soldNums = [0.05,0.45,0.15,0.35]

# 繪製餅狀圖
plt.pie(soldNums,
        labels=kinds,
        autopct="%3.1f%%",
        startangle=60,
        colors=colors)

plt.title("不同型別的箱子的銷售數量佔比")

plt.show()

在這裡插入圖片描述

相關文章