2

这是进行瀑布表示的尝试。我需要用不同的颜色表示信号(数组)值(幅度/电平/密度),而不是像所做的那样以阴影表示。因为我是算法和信号处理工程师。而不是软件开发人员,我不熟悉彩色地图和这些东西。因此,如果有人可以用将颜色与信号值相关联的代码来帮助我。

from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph.opengl as gl
import scipy.ndimage as ndi
import numpy as np

Nf = 90     # No. of frames
Ns = 100    # Signal length

app = QtGui.QApplication([])

w_SA = QtGui.QWidget(); w_SA.setFixedSize(400, 400)

# Create a GL View widget to display data
plt_SA1 = gl.GLViewWidget(w_SA); plt_SA1.move(10, 10); plt_SA1.resize(380, 380)
plt_SA1.setCameraPosition(elevation=90.0, azimuth=0.0, distance=70)
p1 = gl.GLSurfacePlotItem(shader='shaded', color=(0.5, 0.5, 1, 1), smooth=False)
p1.translate(-Nf/2, -Ns/2, 0)
plt_SA1.addItem(p1)

Arx = np.zeros([Nf, Ns])
def update():
    global Arx
    Arx = np.roll(Arx, 1, axis=0)
    Arx[0] = ndi.gaussian_filter(np.random.normal(size=(1,Ns)), (1,1))
    p1.setData(z=Arx)
timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(30)

w_SA.show()

if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
4

1 回答 1

2

您能否更具体地说明您希望图像如何着色?如果您不需要 OpenGL,这里有一个使用 pyqtgraph.ImageView 的更简单的解决方案。您可以右键单击右侧的渐变栏以更改用于为图像着色的查找表。手动设置此表的方法也有多种,具体取决于所需的效果。

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

Nf = 90     # No. of frames
Ns = 100    # Signal length

app = QtGui.QApplication([])

Arx = np.zeros([Nf, Ns])
win = pg.image(Arx)
win.view.setAspectLocked()
def update():
    global Arx
    Arx = np.roll(Arx, 1, axis=0)
    Arx[0] = ndi.gaussian_filter(np.random.normal(size=(1,Ns)), (1, 1))
    win.setImage(Arx.T, autoRange=False)

timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(30)

if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
于 2013-09-17T15:11:31.287 回答