Pie Chart

In [117]: import matplotlib.pyplot as plt

In [118]: data = [5,25,50,20]

               plt.pie(data)

               plt.show()

https://img-blog.csdnimg.cn/20190220123316661.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0xpbmxpNTIyMzYyMjQy,size_16,color_FFFFFF,t_70

4 Using custom colors for pie charts

In [29]: import numpy as np

             import matplotlib.pyplot as plt

In [35]: values = np.random.rand(8)#generating 8 numbers with 0<=values<1

             color_set = ('.00', '.25', '.50', '.75')

             #If there are less colors than values, then pyplot.pie() will simply cycle through the color li

             #each color will be used twice.in our example

In [37]: plt.pie(values, colors=color_set)

             plt.show()

猜你喜欢

转载自blog.csdn.net/Linli522362242/article/details/87891575
pie
今日推荐