数据可视化之matplotlib实战:plt.pie()函数 绘制饼状图

    科技2022-07-10  161

    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()

    Processed: 0.027, SQL: 8