您需要使用 imshow 选项重新缩放像素:形状和范围:
import numpy as np
import matplotlib.pyplot as plt
shape = (112, 2182)
extent = [0, 112, 0, 2182]
data = np.random.random_sample(shape)
plt.figure(figsize=(5, 3.5))
ax = plt.subplot(111)
plt.axis('off')
dx = (extent[1] - extent[0]) / shape[1]
dy = (extent[3] - extent[2]) / shape[0]
dx_dy = dx/dy
im = ax.imshow(data, extent=extent, aspect=dx_dy)
plt.show()
缥缈止盈
相关分类