Exemple #1
0
    def plot_path(self, data):
        # at this stage, plot is rendered and size known
        if not self.zoom_initialized:
            self.monitor_zoom_level()
            self.zoom_initialized = True

        path = hv.Path(data)
        path.opts(
            opts.Path(line_width=self.tool_width * self.zoom_level + 1,
                      color=self.cmap[self.dataset.drawing_label],
                      line_cap='round',
                      line_join='round'))

        return path
Exemple #2
0
    def __init__(self, adh_mod, **params):
        super(InterpolateMesh, self).__init__(adh_mod=adh_mod, **params)
        # set defaults for initialized example
        self.display_range.param.color_range.bounds = (10, 90)
        self.display_range.color_range = (10, 90)
        self.cmap_opts.colormap = cc.rainbow
        self.scatter_projection.set_crs(ccrs.GOOGLE_MERCATOR)
        self.adh_mod.wmts.source = gv.tile_sources.EsriImagery

        # print(self.projection.param.UTM_zone_hemi.constant, self.projection.crs_label)
        self.opts = (opts.Curve(height=self.map_height,
                                width=self.map_width,
                                xaxis=None,
                                line_width=1.50,
                                color='red',
                                tools=['hover']),
                     opts.Path(height=self.map_height,
                               width=self.map_width,
                               line_width=3,
                               color='black'),
                     opts.Image(height=self.map_height,
                                width=self.map_width,
                                cmap=self.cmap_opts.param.colormap,
                                clim=self.display_range.param.color_range,
                                colorbar=True,
                                clipping_colors={
                                    'NaN': 'transparent',
                                    'min': 'transparent'
                                },
                                axiswise=True),
                     opts.RGB(height=self.map_height, width=self.map_width),
                     opts.Points(height=self.map_height,
                                 width=self.map_width,
                                 color_index='z',
                                 cmap=self.cmap_opts.param.colormap,
                                 clim=self.display_range.param.color_range,
                                 size=10,
                                 tools=['hover'],
                                 padding=(0.1, 0.1),
                                 colorbar=True),
                     opts.TriMesh(height=self.map_height,
                                  width=self.map_width,
                                  color_index='z',
                                  cmap=self.cmap_opts.param.colormap,
                                  clim=self.display_range.param.color_range,
                                  tools=['hover'],
                                  padding=(0.1, 0.1),
                                  colorbar=True), opts.VLine(color='black'))
Exemple #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # grey glyph for drawing label -1 (unlabeled)
        self.cmap[-1] = '#999999'

        self.path_plot = hv.DynamicMap(self.plot_path, streams=[self.pipe])
        self.freehand.source = self.path_plot

        self.path_plot.opts(opts.Path(active_tools=['freehand_draw']))
        self.pointer_pos.source = self.path_plot
        self.clicked_pos.source = self.path_plot
        self.zoom_range.source = self.path_plot
        self.plot_size.source = self.path_plot

        self.path_plot = self.path_plot * hv.DynamicMap(self.plot_pointer)
Exemple #4
0
    def view(self):
        data = self.data
        xmin, xmax = np.min(data), np.max(data)
        x1_dim = hv.Dimension('x₁', range=(xmin, xmax))
        x2_dim = hv.Dimension('x₂', range=(xmin, xmax))

        samples_map = self.maps["samples"]
        samples_map = samples_map.opts(width=600,
                                       height=350,
                                       show_grid=True,
                                       padding=(0, 0.1),
                                       toolbar=None)
        samples_map = samples_map.opts(opts.Path(color=blue, framewise=True))
        samples_map = samples_map.redim.label(y="f(x)", x="x")

        control_vline_map = self.maps["vlines_control"]
        control_vline_map = control_vline_map.redim(x=x1_dim, y=x2_dim)
        control_vline_map = control_vline_map.opts(show_grid=True)
        control_vline_map = control_vline_map.opts(
            opts.HLine(line_width=2), opts.VLine(line_width=2),
            opts.Points(color="white", marker="s", size=8),
            opts.Image(cmap="viridis"))

        vlines_map = self.maps["vlines"]
        vlines_map = vlines_map.opts(toolbar=None)
        vlines_map = vlines_map.opts(opts.VLine(line_width=2),
                                     opts.Points(size=6))

        scatter_map = self.maps["scatter"]
        scatter_map = scatter_map.redim.label(y="f(x₂)", x="f(x₁)")
        scatter_map = scatter_map.opts(padding=(0.5, 0.5),
                                       show_grid=True,
                                       toolbar=None)
        scatter_map = scatter_map.opts(
            opts.Scatter(size=7,
                         framewise=True,
                         fill_color=orange1,
                         line_color=orange2))

        title = pn.pane.Markdown("## GP samples visualization", max_height=25)
        descr = pn.pane.Markdown(
            "_For moving x₁ and x₂ bars: 1. turn off **pan** tool, 2. click and move the orange squared point on the covariance matrix_"
        )
        row0 = pn.Row(pn.Spacer(width=25), self.kernels_controller.view())
        row1 = samples_map * vlines_map
        row2 = pn.Row(control_vline_map, scatter_map)
        return pn.Column(title, descr, row0, row1, row2)
Exemple #5
0
def get_plot(path, poly):
    return (path * poly).opts(
        opts.Polygons(fill_alpha=0.3, active_tools=["poly_draw"]),
        opts.Path(color=LINE, height=400, line_width=5, width=400),
    )
Exemple #6
0
# Then convert the 3D data into a holoviews dataset

nx, ny, nz = mat.shape
rock = hv.Dataset((np.arange(nx), np.arange(ny), np.arange(nz), mat),
                  ["x", "y", "z"], ["value"])
rock = rock.clone(datatype=['xarray'])
rock.data

from holoviews import opts
opts.defaults(
    opts.GridSpace(shared_xaxis=True, shared_yaxis=True),
    opts.Image(cmap='Gray', width=400, height=400),
    opts.Labels(text_color='white',
                text_font_size='8pt',
                text_align='left',
                text_baseline='bottom'), opts.Path(color='white'),
    opts.Spread(width=600), opts.Overlay(show_legend=False))

# Data has three dimensions. We can easily visualise two using an image, and use a slider to change the third dimension.

rock.to(hv.Image, ['x', 'y'], datatype=["xarray"], dynamic=True).hist()

# To make it more interesting we can create three plots and each having one of the dimensions on the slider.
#
# Here's we use the [Turbo](https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html) colormap which is often better than viridis or plasma for highlighting differences

import bokeh.palettes as pal

# %%opts Image {+axiswise} [xaxis=None yaxis=None width=200 height=200]
cmap = pal.Turbo256
hmx = rock.to(hv.Image, ['z', 'y'], dynamic=True).opts(cmap=cmap)
Exemple #7
0
# %%
st, sc, sy, sx = xp.shape

# %%

ds = hv.Dataset((np.arange(sy),
                 np.arange(sx),
                 np.arange(st), xp[:,1,:,:]),
                ['x','y', 'Frame'], 'movie')

# %%
#ds.clone(datatype=['xarray']).data


# %%
opts.defaults(
    opts.GridSpace(shared_xaxis=True, shared_yaxis=True),
    opts.Image(cmap='viridis', width=400, height=400),
    opts.Labels(text_color='white', text_font_size='8pt', text_align='left', text_baseline='bottom'),
    opts.Path(color='white'),
    opts.Spread(width=600),
    opts.Overlay(show_legend=False))
# %%
ds.to(hv.Image, ['x', 'y']).hist()


# %%
#np.save('xp.npy', xp)

# %%