allow to set color map

This commit is contained in:
2023-05-12 14:59:18 +02:00
parent cf24d54b62
commit dcc554eab8

View File

@ -1,16 +1,18 @@
import numpy as np
import pyqtgraph as pg
from .desc import Description
class ImageDescription(Description):
def __init__(self, name, title=None, xlabel=None, ylabel=None, image=None, levels=None):
def __init__(self, name, title=None, xlabel=None, ylabel=None, image=None, levels=None, cmap="viridis"):
self.name = name
self.title = title
self.xlabel = xlabel
self.ylabel = ylabel
self.image = image
self.levels = levels #TODO: might be better to use vmin and vmax
self.cmap = cmap
@property
def data(self):
@ -40,6 +42,10 @@ class ImageDescription(Description):
if self.ylabel:
plotwidget.getView().setLabel("left", self.ylabel)
if self.cmap:
cm = pg.colormap.get(self.cmap)
plotwidget.setColorMap(cm)
return res