Matplotlib 拉伸轴刻度以适合压缩图像

Matplotlib 拉伸轴刻度以适合压缩图像,matplotlib,axis,stretching,Matplotlib,Axis,Stretching,我有一个PyQt4应用程序,其中使用matplotlib表示16位灰度图像。我所代表的图像相当大。由于内存限制,很遗憾,我无法表示更大的图像,因此我以这种方式对它们进行切片: ImageDataArray[::ratio, ::ratio] 显示绘图时,轴会根据比率进行压缩。因此,图像的坐标对于知道感兴趣的信息的位置非常重要,我想通过比率因子再次拉伸轴 如何进行管理,以便即使使用matplotlib工具栏中的缩放功能,也能显示正确的坐标 提前谢谢 代码: 您想使用imshow 您想使用imsh

我有一个PyQt4应用程序,其中使用matplotlib表示16位灰度图像。我所代表的图像相当大。由于内存限制,很遗憾,我无法表示更大的图像,因此我以这种方式对它们进行切片:

ImageDataArray[::ratio, ::ratio]
显示绘图时,轴会根据比率进行压缩。因此,图像的坐标对于知道感兴趣的信息的位置非常重要,我想通过比率因子再次拉伸轴

如何进行管理,以便即使使用matplotlib工具栏中的缩放功能,也能显示正确的坐标

提前谢谢

代码:


您想使用
imshow


您想使用
imshow


你把它整理好了吗?你把它整理好了吗?只是为了添加,解释了如何保持你的纵横比。只是为了添加,解释了如何保持你的纵横比。
from numpy import fromfile, uint16, shape
import matplotlib.pyplot as plt

data = fromfile('D:\\ImageData.raw', dtype=uint16)
data.resize((ysize,xsize))
xmin = 0
ymin = 0
xmax = shape(data)[1]
ymax = shape(data)[0]
ratio = max(max(shape(data)[0], shape(data)[1])/2000, 1)
data_slice = data[ymin:ymax:ratio, xmin:xmax:ratio]
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.imshow(data_slice, cmap='gray', interpolation='nearest')
plt.show()
ax.imshow(...,extent=[xmin,xmax,ymin,ymax])