-
-
Save campagnola/8966909 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyqtgraph as pg | |
from pyqtgraph.Qt import QtGui, QtCore | |
pg.mkQApp() | |
## Create window with two ImageView widgets | |
win = QtGui.QMainWindow() | |
win.resize(800,800) | |
win.setWindowTitle('pyqtgraph example: DataSlicing') | |
cw = QtGui.QWidget() | |
win.setCentralWidget(cw) | |
l = QtGui.QGridLayout() | |
l.setRowStretch(0, 10) | |
l.setRowStretch(1, 2) | |
l.setRowStretch(2, 2) | |
cw.setLayout(l) | |
dummy_plot= pg.PlotItem(title='Pilatus image') | |
dummy_plot.enableAutoRange() | |
imv1 = pg.ImageView(view=dummy_plot ) | |
# imv1 = pg.ImageView() | |
pw = pg.PlotWidget() | |
pw2 = pg.PlotWidget() | |
pw3 = pg.PlotWidget() | |
# imv2 = pg.ImageView() | |
l.addWidget(imv1, 0, 0) | |
l.addWidget(pw, 1, 0) | |
l.addWidget(pw2, 2, 0) | |
win.show() | |
roi = pg.LineSegmentROI([[10, 64], [120,64]], pen='r') | |
imv1.addItem(roi) | |
data = pg.np.random.normal(size=(100,100,100)) | |
time = pg.np.linspace(0, 10, 100) | |
def update(): | |
global data, imv1, pw, roi | |
pw.clear() | |
pw2.clear() | |
d2 = roi.getArrayRegion(data, imv1.imageItem, axes=(1,2)) | |
pw.plot(d2[imv1.currentIndex], pen=roi.pen) | |
pw2.plot(d2[1], pen=[5,8]) | |
roi.sigRegionChanged.connect(update) | |
imv1.sigTimeChanged.connect(update) | |
imv1.setImage(data, xvals=time)#, axes= {'t':2, 'x':0, 'y':1, 'c':3},transform=) | |
update() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment