def test_NonUniformImage_colormap(): window = pg.GraphicsLayoutWidget() viewbox = pg.ViewBox() window.setCentralWidget(viewbox) window.resize(200, 200) window.show() x = [1.0, 3.0, 10.0] y = [1.0, 2.0, 4.0] X, Y = np.meshgrid(x, y, indexing='ij') Z = X * Y Z[:, 0] = [np.NINF, np.NAN, np.PINF] image = NonUniformImage(x, y, Z, border=fn.mkPen('g')) cmap = ColorMap(pos=[0.0, 1.0], color=[(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)]) image.setColorMap(cmap) viewbox.addItem(image) QtTest.QTest.qWaitForWindowExposed(window) QtTest.QTest.qWait(100) assertImageApproved(window, 'nonuniform_image/colormap-3x3')
def colorMap(self): """Return a ColorMap object representing the current state of the editor.""" if self.colorMode == 'hsv': raise NotImplementedError('hsv colormaps not yet supported') pos = [] color = [] for t,x in self.listTicks(): pos.append(x) c = t.color color.append([c.red(), c.green(), c.blue(), c.alpha()]) return ColorMap(np.array(pos), np.array(color, dtype=np.ubyte))