一、总结
一句话总结:
plt.imshow(data) 将数值转成颜色
plt.colorbar() 显示颜色基准条
data=np.random.uniform(0,1.0,9).reshape((3,3))
# plt.imshow(data,interpolation='nearest',cmap='bone',origin='upper')
plt.imshow(data)
# color缩小为原来的90%
plt.colorbar(shrink=0.9)
二、image图片
博客对应课程的视频位置:
import matplotlib.pyplot as plt
import numpy as np
data=np.random.uniform(0,1.0,9).reshape((3,3))
print(data)
data
"""
for the value of"interpolation",check this:
http://matplotlib.org/examples/images_contours_and_fields/interpolation_methods.html
"""
# plt.imshow(data,interpolation='nearest',cmap='bone',origin='upper')
plt.imshow(data)
# color缩小为原来的90%
plt.colorbar(shrink=0.9)
plt.xticks(())
plt.yticks(())
plt.show()
结果:
[[0.50867287 0.16963109 0.87560028]
[0.19614212 0.94408617 0.18405361]
[0.50226809 0.00187141 0.58463625]]