將一個(gè)二維數(shù)組顯示為圖片
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
data = np.linspace(0, 1, 40000).reshape(-1, 200)
ax1 = fig.add_subplot(3, 2, 1)
ax1.imshow(data)
ax2 = fig.add_subplot(3, 2, 2)
# show all the color map style: plt.colormaps()
ax2.imshow(data, cmap='hot')
ax3 = fig.add_subplot(3, 2, 3)
# origin default is upper left
ax3.imshow(data, origin='lower', cmap='hot')
ax4 = fig.add_subplot(3, 2, 4)
# scale the coordinates
ax4.imshow(data, cmap='hot', extent=(10, 20, 0, 10))
plt.show()
圖1使用默認(rèn)設(shè)置,圖2自定義了顏色映射勺良,圖三將數(shù)組的元素從左下角開(kāi)始放绰播,圖4縮放了坐標(biāo)軸。