How to use the holoviews.Curve function in holoviews

To help you get started, we’ve selected a few holoviews examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DeniseCaiLab / minian / minian / visualization.py View on Github external
def _temp_comp_sub(self, usub=None):
        if usub is None:
            usub = self.strm_usub.usub
        if self._normalize:
            C, S = self.C_norm_sub, self.S_norm_sub
        else:
            C, S = self.C_sub, self.S_sub
        cur_temp = dict()
        if self._showC:
            cur_temp['C'] = (
                hv.Dataset(C.sel(unit_id=usub)
                           .compute().rename("Intensity (A. U.)")
                           .dropna('frame', how='all')).to(hv.Curve, 'frame'))
        if self._showS:
            cur_temp['S'] = (
                hv.Dataset(S.sel(unit_id=usub)
                           .compute().rename("Intensity (A. U.)")
                           .dropna('frame', how='all')).to(hv.Curve, 'frame'))
        cur_vl = (hv.DynamicMap(
            lambda f, y: hv.VLine(f) if f else hv.VLine(0),
            streams=[self.strm_f])
                  .opts(style=dict(color='red')))
        cur_cv = hv.Curve([], kdims=['frame'], vdims=['Internsity (A.U.)'])
        self.strm_f.source = cur_cv
        h_cv = len(self._w) // 8
        w_cv = len(self._w) * 2
        temp_comp = (cur_cv
                     * datashade_ndcurve(hv.HoloMap(cur_temp, 'trace')
                                         .collate().overlay('trace')
github holoviz / holoviews / tests / testcharts.py View on Github external
def test_chart_slice(self):
        chart_slice = Curve(zip(range(5, 9), np.linspace(0.5,0.8, 4)))
        self.assertEqual(self.curve[5:9], chart_slice)
github holoviz / holoviews / tests / core / testtraversal.py View on Github external
def test_unique_keys_partial_overlap(self):
        hmap1 = HoloMap({(i, j): Curve(range(10)) for i in range(5) for j in range(3)}, kdims=['A', 'B'])
        hmap2 = HoloMap({i: Curve(range(10)) for i in range(5)}, kdims=['A'])
        dims, keys = unique_dimkeys(hmap1+hmap2)
        self.assertEqual(hmap1.kdims, dims)
        self.assertEqual(keys, [(i, j) for i in range(5) for j in list(range(3))])
github holoviz / holoviews / tests / core / testtraversal.py View on Github external
        dmap1 = DynamicMap(lambda A: Curve(range(10)), kdims=['A'])
        dmap2 = DynamicMap(lambda B: Curve(range(10)), kdims=['B'])
github holoviz / holoviews / tests / operation / testdatashader.py View on Github external
def test_aggregate_curve(self):
        curve = Curve([(0.2, 0.3), (0.4, 0.7), (0.8, 0.99)])
        expected = Image(([0.25, 0.75], [0.25, 0.75], [[1, 0], [1, 1]]),
                         vdims=['Count'])
        img = aggregate(curve, dynamic=False,  x_range=(0, 1), y_range=(0, 1),
                        width=2, height=2)
        self.assertEqual(img, expected)
github holoviz / holoviews / tests / ipython / testdisplayhooks.py View on Github external
def test_store_render_png(self):
        curve = Curve([1, 2, 3])
        data, metadata = Store.render(curve)
        mime_types = {'image/png'}
        self.assertEqual(set(data), mime_types)
github flatironinstitute / CaImAn / caiman / utils / visualization.py View on Github external
def plot_unit(uid, scl):
        trace = (
            hv.Curve(Y_r[uid, :], kdims='frame #').opts(framewise=True)
            * (hv.Curve(C[uid, :], kdims='frame #')
               .opts(color=denoised_color, framewise=True))
        ).opts(aspect=3, frame_height=200)
        A_scl = norm(Ad[:, :, uid], (scl, 1))
        im_hsv_scl = im_hsv.copy()
        im_hsv_scl[:, :, 2] = im_hsv[:, :, 2] * A_scl
        im_u = (hv.HSV(im_hsv_scl, kdims=['height', 'width'])
                .opts(aspect='equal', frame_height=200))
        return hv.Layout([im_u] + [trace]).cols(1) #im_u + trace
github DeniseCaiLab / minian / minian / visualization_ply.py View on Github external
ds_mean = self.ds.aggregate(dimensions='frame', function=np.mean)
        ds_max = self.ds.aggregate(dimensions='frame', function=np.max)
        ds_min = self.ds.aggregate(dimensions='frame', function=np.min)
        for dim in self.ds.vdims:
            cur_d = self.ds.reindex(vdims=[dim.name])
            fim = fct.partial(self._img, dat=cur_d)
            im = hv.DynamicMap(fim, streams=[self.stream])
            im = regrid(im, height=480, width=752)
            im = im(plot={'width': 752, 'height': 480})
            xyrange = RangeXY(source=im)
            xyrange = xyrange.rename(x_range='w', y_range='h')
            fhist = fct.partial(self._hist, dat=cur_d)
            hist = hv.DynamicMap(fhist, streams=[self.stream, xyrange])
            hist = hist(plot={'width': 200})
            cur_mdict = OrderedDict()
            dmean = hv.Curve(ds_mean, kdims='frame', vdims=dim.name)
            cur_mdict['mean'] = dmean(plot={'tools': ['hover']})
            dmax = hv.Curve(ds_max, kdims='frame', vdims=dim.name)
            cur_mdict['max'] = dmax(plot={'tools': ['hover']})
            dmin = hv.Curve(ds_min, kdims='frame', vdims=dim.name)
            cur_mdict['min'] = dmin(plot={'tools': ['hover']})
            mean = hv.NdOverlay(cur_mdict, kdims=['variable'])
            if use_datashade:
                c_keys = OrderedDict()
                legends = OrderedDict()
                c_keys['mean'] = Sets1to3[0]
                legends['mean'] = hv.Points([0, 0]).opts(
                    style=dict(color=Sets1to3[0]))
                c_keys['max'] = Sets1to3[1]
                legends['max'] = hv.Points([0, 0]).opts(
                    style=dict(color=Sets1to3[1]))
                c_keys['min'] = Sets1to3[2]
github DeniseCaiLab / minian / minian / visualization.py View on Github external
hv_pts = hv.HoloMap(hv_pts_dict, kdims=kdims)
    hv_A = hv.HoloMap(hv_A_dict, kdims=kdims)
    hv_Ab = hv.HoloMap(hv_Ab_dict, kdims=kdims)
    hv_C = (hv.HoloMap(hv_C_dict, kdims=kdims).collate()
            .grid('unit_id').add_dimension('time', 0, 0))
    if datashading:
        hv_A = regrid(hv_A)
        hv_Ab = regrid(hv_Ab)
        hv_C = datashade(hv_C)
    hv_A = hv_A.opts(frame_width=400, aspect=w/h,
                     colorbar=True, cmap='viridis')
    hv_Ab = hv_Ab.opts(frame_width=400, aspect=w/h,
                       colorbar=True, cmap='viridis')
    hv_C = hv_C.map(
        lambda cr: cr.opts(frame_width=500, frame_height=50),
        hv.RGB if datashading else hv.Curve)
    return (hv.NdLayout({
        'pseudo-color': (hv_pts * hv_A),
        'binary': (hv_pts * hv_Ab)}, kdims='Spatial Matrix').cols(1)
            + hv_C.relabel('Temporal Components'))
github glotaran / pyglotaran / glotaran / report / svd.py View on Github external
def _svd(dataset: xr.Dataset, value: str, nr_svals: int, log_scale_time):

    nr_svals = min(nr_svals, dataset.coords['singular_value_index'].size)
    data = dataset[f'{value}_left_singular_vectors']
    lsv = hv.Curve(data.sel(left_singular_value_index=0))
    for i in range(1, nr_svals):
        lsv *= hv.Curve(data.sel(left_singular_value_index=i))

    lsv = lsv.options(hv.opts.Curve(logx=log_scale_time, framewise=True))

    data = dataset[f'{value}_right_singular_vectors']
    rsv = hv.Curve(data.sel(right_singular_value_index=0))
    for i in range(1, nr_svals):
        rsv *= hv.Curve(data.sel(right_singular_value_index=i))

    rsv = rsv.options(hv.opts.Curve(logx=log_scale_time, framewise=True))

    svals = hv.Curve(dataset[f'{value}_singular_values']).options(logy=True)

    return lsv + svals + rsv