matplotlib显示栅格图片

 参考自Matplotlib Python 画图教程 (莫烦Python)(13)_演讲•公开课_科技_bilibili_哔哩哔哩 https://www.bilibili.com/video/av16378354/index_10.html#page=13

"""输出栅格图片"""


import numpy as np
import matplotlib.pyplot as plt

# image data
a = np.array([0.3136, 0.4653, 0.5237, 0.2453, 0.7395,
              0.1250, 0.4237, 0.8230, 0.6515]).reshape(3, 3)

# 插值方法为最临近插值,还有双线性插值等,origin表示a矩阵的方向lower是对调
plt.imshow(a, interpolation='nearest', cmap='bone', origin='upper')
plt.colorbar(shrink=0.9)  # colorbar压缩为栅格高度的90%

plt.xticks([])
plt.yticks([])
plt.show()

 

posted @ 2018-01-07 21:02  Laumians  阅读(1115)  评论(0编辑  收藏  举报