10.all_pipe - wwj-2017-1117/graph GitHub Wiki

画饼状图(1)--默认是椭圆

import matplotlib.pyplot as plt

labels = 'A', 'B', 'C', 'D' fraces = [15, 30, 45, 10] plt.pie(x=fraces, labels=labels) plt.show()

画饼状图(2)

椭圆变标准圆,plt.axes(aspect=1)

import matplotlib.pyplot as plt

labels = 'A', 'B', 'C', 'D' fraces = [15, 30, 45, 10] plt.axes(aspect=1) plt.pie(x=fraces, labels=labels) plt.show()# 画饼状图(3)

在图上显示所占份额 autopct='%0f%%'

import matplotlib.pyplot as plt

labels = 'A', 'B', 'C', 'D' fraces = [15, 30, 45, 10] plt.axes(aspect=1) plt.pie(x=fraces, labels=labels, autopct='%0f%%') plt.show()

画饼状图(4), 突出重点,分离某一块explode= explode

import matplotlib.pyplot as plt

labels = 'A', 'B', 'C', 'D' fraces = [15, 30, 45, 10] explode = [0, 0.1, 0, 0] plt.axes(aspect=1) plt.pie(x=fraces, labels=labels, autopct='%0f%%', explode=explode) plt.show()

画饼状图(5), 实现立体感 有阴影 shadow=True

import matplotlib.pyplot as plt

labels = 'A', 'B', 'C', 'D' fraces = [15, 30, 45, 10] explode = [0, 0.1, 0, 0] plt.axes(aspect=1) plt.pie(x=fraces, labels=labels, autopct='%0f%%', explode=explode, shadow=True) plt.show()