"""
Data Slicer demo cut down and rewritten to be RGB[A] rather than monochrome.
"""
import numpy as np
import pyqtgraph as pg
from pyqtgraph.Qt import QtWidgets
app = pg.mkQApp("RGB[A] Data Slicing Example")
## Create window with two ImageView widgets
win = QtWidgets.QMainWindow()
win.resize(800,800)
imv = pg.ImageView()
win.setCentralWidget(imv)
win.show()
x1 = np.linspace(-30, 10, 128)[:, np.newaxis, np.newaxis]
x2 = np.linspace(-20, 20, 128)[:, np.newaxis, np.newaxis]
y = np.linspace(-30, 10, 128)[np.newaxis, :, np.newaxis]
z = np.linspace(-20, 20, 128)[np.newaxis, np.newaxis, :]
d1 = np.sqrt(x1**2 + y**2 + z**2)
d2 = 2*np.sqrt(x1[::-1]**2 + y**2 + z**2)
d3 = 4*np.sqrt(x2**2 + y[:,::-1]**2 + z**2)
# Create R, G and B channels
data = np.empty([128, 128, 128, 3]) # alternatively you can stack the arrays with numpy to make the 4th axis
data[:, :, :, 0] = (np.sin(d1) / d1**2)
data[:, :, :, 1] = (np.sin(d2) / d2**2)
data[:, :, :, 2] = (np.sin(d3) / d3**2)
## Display the data
imv.setImage(data, levelMode='rgba')
imv.setLevels(-0.003, 0.003)
# Hide the stuff that gets in the way
imv.ui.histogram.hide()
imv.ui.roiBtn.hide()
imv.ui.menuBtn.hide()
if __name__ == '__main__':
pg.exec()
--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CAD_p8v2gwr81GY9FPA%3DoBXcmgsyp8g0oyUbK%2BbXe7ZiCvu8PPA%40mail.gmail.com.