ImageView.setImage轴参数不切换X-Y尺寸

时间:2015-06-21 09:55:19

标签: pyqtgraph

我通过添加语句data[:, ::10, :] = 0修改了ImageView示例,该语句将中间维度的每个第十个元素设置为0.程序现在显示水平线。这与ImageView.setImage函数的文档一致:默认轴字典为{'t':0, 'x':1, 'y':2, 'c':3}。但是,当我将其更改为{'t':0, 'x':2, 'y':1, 'c':3}时,没有什么会改变我希望获得垂直行的位置。

所以我的问题是:如何在PyQtGraph中为行维度赋予更高的优先级?当然,在将它们传递给setImage函数之前,我可以自己转置所有数组,但我不愿意。特别是因为Numpy和Qt都使用行/列约定而不是Y之前的X.我不明白为什么PyQtGraph会选择后者。

为了完整性,请在下面找到我修改过的ImageView示例。

import numpy as np
from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph as pg

app = QtGui.QApplication([])

## Create window with ImageView widget
win = QtGui.QMainWindow()
win.resize(800,800)
imv = pg.ImageView()
win.setCentralWidget(imv)
win.show()
win.setWindowTitle('pyqtgraph example: ImageView')

## Create random 3D data set with noisy signals
img = pg.gaussianFilter(np.random.normal(size=(200, 200)), (5, 5)) * 20 + 100
img = img[np.newaxis,:,:]
decay = np.exp(-np.linspace(0,0.3,100))[:,np.newaxis,np.newaxis]
data = np.random.normal(size=(100, 200, 200))
data += img * decay
data += 2

## Add time-varying signal
sig = np.zeros(data.shape[0])
sig[30:] += np.exp(-np.linspace(1,10, 70))
sig[40:] += np.exp(-np.linspace(1,10, 60))
sig[70:] += np.exp(-np.linspace(1,10, 30))

sig = sig[:,np.newaxis,np.newaxis] * 3
data[:,50:60,50:60] += sig

data[:, ::10, :] = 0 # Make image a-symmetrical

## Display the data and assign each frame a time value from 1.0 to 3.0
imv.setImage(data, xvals=np.linspace(1., 3., data.shape[0]), 
             axes={'t':0, 'x':2, 'y':1, 'c':3}) # doesn't help

## Start Qt event loop unless running in interactive mode.
if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()

1 个答案:

答案 0 :(得分:1)

浏览ImageView.py, setImage()解析轴词典并根据“' t”的存在情况进行解析。它构建了z轴/框架滑块,就是这样。重新排列轴似乎未实现