1 import matplotlib.pyplot as plt 2 labels = [‘Nokia‘,‘Samsung‘,‘Apple‘,‘Lumia‘] 3 values = [10,30,45,15] 4 colors = [‘yellow‘,‘green‘,‘red‘,‘blue‘] 5 6 #其中,labels、values、colors,explode(当然explode数组中的个数与上面对应,而且每个值的范围介于0-1之前)的对应关系:‘Nokia‘-10-yellow-0,‘Samsung‘-30-green-0.1,‘Apple‘-45-red-0.2,‘Lumia‘-15-blue-0 7 explode = [0,0.1,0.2,0] 8 plt.pie(values,labels=labels,colors=colors,explode=explode) 9 plt.axis(‘equal‘) 10 plt.show()
时间: 2024-11-05 14:45:22