25-Jul-2019 争取每天看一小时python
Case1
import matplotlib.image as mpimg
img = mpimg.imread('bug.png')
lum_img = img[:, :, 2] #第一个:是纵坐标的范围,第二个:是横坐标范围,第三个是色度
plt.imshow(lum_img)
#也可以这样写:
# imgplot = plt.imshow(lum_img)
# imgplot.set_cmap('nipy_spectral')
plt.colorbar()
plt.show()
imgplot = plt.imshow(lum_img,cmap='nipy_spectral')```
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190725215850980.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1dlbk51YW5fOHNh,size_16,color_FFFFFF,t_70)
Case2
#Pie chart, where the slices will be ordered and plotted counter-clockwise: 逆时针转
labels = 'Rent', 'Meal', 'tranportation', 'makeup'
sizes = [45, 30, 15, 10]
explode = (0.1, 0, 0, 0) # only "explode" the 1st slice (i.e. 'Rent')
plt.figure()
plt.pie(sizes, explode=explode, labels=labels, autopct='%1.2f%%', #小数点前面不影响,小数点后面是保留几位小数
shadow=True, startangle=90) #是否有隐形,第一个饼从多少度开始的
plt.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
plt.show()