饼图
1、饼图
import matplotlib.pyplot as plt
sizes = [3,7]
plt.pie(sizes)
plt.show()
import matplotlib.pyplot as plt
sizes = [2,1,1,2,1,3]
plt.pie(sizes)
plt.show()
2、pie函数
def pie(x, explode=None, labels=None, colors=None, autopct=None,
pctdistance=0.6, shadow=False, labeldistance=1.1, startangle=None,
radius=None, counterclock=True, wedgeprops=None, textprops=None,
center=(0, 0), frame=False, rotatelabels=False, hold=None, data=None)
import matplotlib.pyplot as plt
sizes = [2,1,1,2,1,3]
explodes=[0,0,0,0,0,0.1]
plt.pie(sizes,explode=explodes)
plt.show()
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
sizes = [2,1,1,2,1,3]
explodes=[0,0,0,0,0,0.1]
labels=["语文","数学","英语","政治","物理","化学"]
plt.pie(sizes,explode=explodes,labels=labels)
plt.show()