updates the colormap / plot
776354
def _slider_changed(self, n):
        
        self._button_save.setEnabled(True)

        self.modify_colorpoint(n, self._sliders[n].value()*0.001, self._colorpoint_list[n][1], self._colorpoint_list[n][2])
1852
function UpdateChartData()
{
    while(Points > 10)
    {
        Points -= 1;

        myLineChart.removeData();
    }

    myLineChart.addData([Data["Temperature"]], Math.floor((Date.now() - StartTime) / 1000.0));
    myLineChart.update();
    Points+=1;
}
71642
def __update_info(self):
        """"""

        from f311 import explorer as ex
        import f311

        t = self.tableWidget
        z = self.listWidgetVis
        z.clear()
        classes = self.__vis_classes = []
        propss = self.__lock_get_current_propss()
        npp = len(propss)
        s0, s1 = "", ""
        if npp == 1:
            p = propss[0]
            # Visualization options
            if p.flag_scanned:
                if isinstance(p.f, f311.DataFile):
                    classes.extend(f311.get_suitable_vis_classes(p.f))
                    if ex.VisPrint in classes:
                        classes.remove(ex.VisPrint)
                if p.flag_text:
                    # This is an exception, since "txt" is not a Vis descendant.
                    # This will be properly handled in __visualize()
                    classes.append("txt")

                for x in classes:
                    if x == "txt":
                        text = "View plain text"
                    else:
                        text = x.action
                        text += " ("+x.__name__+")"
                    item = QListWidgetItem(text)
                    z.addItem(item)

            # File info
            s0 = p.get_summary()
            s1 = p.get_info()

        elif npp >= 2:
            s0 = "{0:d} selected".format(npp)
            ff = [p.f for p in propss]
            flag_spectra = all([isinstance(f, f311.FileSpectrum) for f in ff])

            # gambiarra to visualize several PFANT .mod files
            has_pyfant = False
            try:
                import pyfant
                has_pyfant = True
            except:
                pass

            flag_mod = False
            if has_pyfant:
                flag_mod = all([isinstance(f, pyfant.FileModBin) and len(f.records) > 1 for f in ff])

            if flag_spectra:
                z.addItem(QListWidgetItem("Plot spectra stacked"))
                classes.append("sta")
                z.addItem(QListWidgetItem("Plot spectra overlapped"))
                classes.append("ovl")
            elif flag_mod:

                # TODO plugin-based way to handle visualization of multiple selection

                z.addItem(QListWidgetItem("View model grid"))
                classes.append("modgrid")
                
        # File info
        self.labelSummary.setText(s0)
        self.textEditInfo.setPlainText(s1)
703705
def _update_callbacks(self, plot):
        
        subplots = self.traverse(lambda x: x, [GenericElementPlot])
        merged_tools = {t: list(plot.select({'type': TOOL_TYPES[t]}))
                        for t in self._merged_tools}
        for subplot in subplots:
            for cb in subplot.callbacks:
                for c in cb.callbacks:
                    for tool, objs in merged_tools.items():
                        if tool in c.args and objs:
                            c.args[tool] = objs[0]
                    if self.top_level:
                        c.code = c.code.replace('PLACEHOLDER_PLOT_ID', self.id)
255020
def add_cmap(name, clst):
    """"""
    global cmaps
    assert len(clst) == min_cmap_len, \
        ValueError("color map '%s' length mismatch %d != %d (needed)" % (
            name, len(clst), min_cmap_len))
    cmaps[name] = ColorMap(name, clst)
1346293
function () {
		var options = this.options,
			userOptions = this.userOptions,
			defaultColors = this.chart.options.colors,
			counters = this.chart.counters,
			color,
			colorIndex;

		color = options.color || defaultPlotOptions[this.type].color;

		if (!color && !options.colorByPoint) {
			if (defined(userOptions._colorIndex)) { // after Series.update()
				colorIndex = userOptions._colorIndex;
			} else {
				userOptions._colorIndex = counters.color;
				colorIndex = counters.color++;
			}
			color = defaultColors[colorIndex];
		}
		
		this.color = color;
		counters.wrapColor(defaultColors.length);
	}
642209
def nx_ensure_agraph_color(graph):
    
    from plottool import color_funcs
    import plottool as pt
    #import six
    def _fix_agraph_color(data):
        try:
            orig_color = data.get('color', None)
            alpha = data.get('alpha', None)
            color = orig_color
            if color is None and alpha is not None:
                color = [0, 0, 0]
            if color is not None:
                color = pt.ensure_nonhex_color(color)
                #if isinstance(color, np.ndarray):
                #    color = color.tolist()
                color = list(color_funcs.ensure_base255(color))
                if alpha is not None:
                    if len(color) == 3:
                        color += [int(alpha * 255)]
                    else:
                        color[3] = int(alpha * 255)
                color = tuple(color)
                if len(color) == 3:
                    data['color'] = '#%02x%02x%02x' % color
                else:
                    data['color'] = '#%02x%02x%02x%02x' % color
        except Exception as ex:
            import utool as ut
            ut.printex(ex, keys=['color', 'orig_color', 'data'])
            raise

    for node, node_data in graph.nodes(data=True):
        data = node_data
        _fix_agraph_color(data)

    for u, v, edge_data in graph.edges(data=True):
        data = edge_data
        _fix_agraph_color(data)
989910
def update_button_action(self):
        
        if self.mode.get() == 3:  # threecolor
            self.configure_threecolor_image()
        elif self.mode.get() == 1:  # singlecolor
            self.configure_singlecolor_image()
        else:
            raise ValueError("mode can only be singlecolor or threecolor")

        self.imageplot.set_data(self.image)
        if self.mode.get() == 1:  # singlecolor
            self.imageplot.set_cmap('gist_gray')
        self.fig.canvas.draw_idle()
15631
def applyColorMap(gray, cmap='flame'):
    '''
    
    '''
    # TODO:implement more cmaps
    if cmap != 'flame':
        raise NotImplemented
    # TODO: make better
    mx = 256  # if gray.dtype==np.uint8 else 65535
    lut = np.empty(shape=(256, 3))
    cmap = (
        # taken from pyqtgraph GradientEditorItem
        (0, (0, 0, 0)),
        (0.2, (7, 0, 220)),
        (0.5, (236, 0, 134)),
        (0.8, (246, 246, 0)),
        (1.0, (255, 255, 255))
    )
    # build lookup table:
    lastval, lastcol = cmap[0]
    for step, col in cmap[1:]:
        val = int(step * mx)
        for i in range(3):
            lut[lastval:val, i] = np.linspace(
                lastcol[i], col[i], val - lastval)

        lastcol = col
        lastval = val

    s0, s1 = gray.shape
    out = np.empty(shape=(s0, s1, 3), dtype=np.uint8)

    for i in range(3):
        out[..., i] = cv2.LUT(gray, lut[:, i])
    return out
1122254
def update_plot_limits(ax, white_space):
    

    if hasattr(ax, 'zz_dataLim'):
        bounds = ax.xy_dataLim.bounds
        ax.set_xlim(bounds[0] - white_space, bounds[0] + bounds[2] + white_space)
        ax.set_ylim(bounds[1] - white_space, bounds[1] + bounds[3] + white_space)

        bounds = ax.zz_dataLim.bounds
        ax.set_zlim(bounds[0] - white_space, bounds[0] + bounds[2] + white_space)
    else:
        bounds = ax.dataLim.bounds
        assert not any(map(np.isinf, bounds)), 'Cannot set bounds if dataLim has infinite elements'
        ax.set_xlim(bounds[0] - white_space, bounds[0] + bounds[2] + white_space)
        ax.set_ylim(bounds[1] - white_space, bounds[1] + bounds[3] + white_space)
1086299
def _add_colorbar(ax: Axes, cmap: colors.Colormap, cmap_data: np.ndarray, norm: colors.Normalize):
    """"""
    fig = ax.get_figure()
    mappable = cm.ScalarMappable(cmap=cmap, norm=norm)
    mappable.set_array(cmap_data)   # TODO: Or what???
    fig.colorbar(mappable, ax=ax)
526354
def heatmap(self, df, imagefile):
        
        import seaborn as sns
        import matplotlib.ticker as tkr
        import matplotlib.pyplot as plt
        from  matplotlib.colors import LinearSegmentedColormap

        sns.set()
        with sns.axes_style('whitegrid'):
            fig, ax = plt.subplots(figsize=(5, 11))  # inches

            cmax = max(df[self.args[2]].max(), self.CMAP_MIN_MAX)
            csteps = {
                0.0: 'darkred', 0.3/cmax: 'red', 0.6/cmax: 'orangered', 0.9/cmax: 'coral',
                1.0/cmax: 'skyblue', 1.5/cmax: 'blue', 1.9/cmax: 'darkblue',
                2.0/cmax: 'darkgreen', 3.0/cmax: 'green',
                (self.CMAP_MIN_MAX - .1)/cmax: 'palegreen', 1.0: 'yellow'}
            cmap = LinearSegmentedColormap.from_list('RdGrYl', sorted(csteps.items()), N=256)

            dataset = df.pivot(*self.args)

            sns.heatmap(dataset, mask=dataset.isnull(), annot=False, linewidths=.5, square=True, ax=ax, cmap=cmap,
                        annot_kws=dict(stretch='condensed'))
            ax.tick_params(axis='y', labelrotation=30, labelsize=8)
            # ax.get_yaxis().set_major_formatter(tkr.FuncFormatter(lambda x, p: x))
            plt.savefig(imagefile)
1340194
def _update_color_hexa(self, event=None):
        """"""
        color = self.hexa.get().upper()
        self.hexa.delete(0, 'end')
        self.hexa.insert(0, color)
        if re.match(r"^#[0-9A-F]{6}$", color):
            r, g, b = hexa_to_rgb(color)
            self.red.set(r)
            self.green.set(g)
            self.blue.set(b)
            h, s, v = rgb_to_hsv(r, g, b)
            self.hue.set(h)
            self.saturation.set(s)
            self.value.set(v)
            self.bar.set(h)
            self.square.set_hsv((h, s, v))
            if self.alpha_channel:
                a = self.alpha.get()
                self.hexa.insert('end', ("%2.2x" % a).upper())
                self.alphabar.set_color((r, g, b, a))
        elif self.alpha_channel and re.match(r"^#[0-9A-F]{8}$", color):
            r, g, b, a = hexa_to_rgb(color)
            self.red.set(r)
            self.green.set(g)
            self.blue.set(b)
            self.alpha.set(a)
            self.alphabar.set_color((r, g, b, a))
            h, s, v = rgb_to_hsv(r, g, b)
            self.hue.set(h)
            self.saturation.set(s)
            self.value.set(v)
            self.bar.set(h)
            self.square.set_hsv((h, s, v))
        else:
            self._update_color_rgb()
        self._update_preview()
550730
def _update_plotting_params(self, **kwargs):
        
        scalars = kwargs.get('scalars', None)
        if scalars is not None:
            old = self.display_params['scalars']
            self.display_params['scalars'] = scalars
            if old != scalars:
                self.plotter.subplot(*self.loc)
                self.plotter.remove_actor(self._data_to_update, reset_camera=False)
                self._need_to_update = True
                self.valid_range = self.input_dataset.get_data_range(scalars)
                # self.display_params['rng'] = self.valid_range
        cmap = kwargs.get('cmap', None)
        if cmap is not None:
            self.display_params['cmap'] = cmap
1042100
def palettize(self, colormap):
        

        if self.mode not in ("L", "LA"):
            raise ValueError("Image should be grayscale to colorize")

        l_data = self.data.sel(bands=['L'])

        def _palettize(data):
            # returns data and palette, only need data
            return colormap.palettize(data)[0]

        new_data = l_data.data.map_blocks(_palettize, dtype=l_data.dtype)
        self.palette = tuple(colormap.colors)

        if self.mode == "L":
            mode = "P"
        else:
            mode = "PA"
            new_data = da.concatenate([new_data, self.data.sel(bands=['A'])], axis=0)

        self.data.data = new_data
        self.data.coords['bands'] = list(mode)
2289
def updateFft(self, *args, **kwargs):
        
        p = kwargs.pop('plot')
        if p == 'response': 
            self.responseFftPlot.updateData(*args, **kwargs)
        else:
            self.stimFftPlot.updateData(*args, **kwargs)
865695
def update_plot!(position = 0, **options)
      return self unless block_given? if options.empty?
      replacement = @plots[position].options!(options)
      yield(replacement) if block_given?
      self
    end