def images( pathstring="kh_*.h5", directory="/home/dominik/FUW/Semestr3/PrezentacjaNiestabilności/pyro2/backup2", interval=2000, figsize=(20, 20), ): p = pathlib.Path(directory) frames = sorted(list(p.glob(pathstring)))[::1] plotfile_name = str(frames[0]) sims = [io.read(str(frame)) for frame in frames] fig = plt.figure(figsize=figsize, dpi=200, facecolor='w') slider = ipywidgets.IntSlider(min=1, max=len(frames) - 1, step=1, continuous_update=True) play = ipywidgets.Play(min=1, max=len(frames) - 1, interval=interval) display(play) ipywidgets.jslink((play, 'value'), (slider, 'value')) def interactive(i): sims[i].dovis() plt.show() return ipywidgets.interactive(interactive, i=slider)
def nb_play_movie(data,interval=30,shape = None,**kwargs): ''' Play a movie from the notebook ''' from ipywidgets import Play,jslink,HBox,IntSlider from IPython.display import display i = _handle_sparse(data[0],shape = shape) im = plt.imshow(i.squeeze(),**kwargs) slider = IntSlider(0,min = 0,max = data.shape[0]-1,step = 1,description='Frame') play = Play(interval=interval, value=0, min=0, max=data.shape[0]-1, step=1, description="Press play", disabled=False) jslink((play, 'value'), (slider, 'value')) display(HBox([play, slider])) def updateImage(change): i = _handle_sparse(data[change['new']],shape=shape) im.set_data(i.squeeze()) slider.observe(updateImage, names='value') return dict(fig = plt.gcf(), ax=plt.gca(), im= im, update = updateImage)
def show(): max_depth = 5 depth = IntSlider(value=1, min=1, max=max_depth, continuous_update=False) play = Play(interval=1000, value=1, min=1, max=max_depth, step=1) jslink((play, 'value'), (depth, 'value')) output = interactive_output(plot, dict(depth=depth)) display(play, output)
def size_widget(self): widget = widgets.IntSlider(value=self.size, min=1, max=max(10, self.size + 5), continuous_update=True) widgets.jslink((self, 'size'), (widget, 'value')) return with_left_label('Point size', widget)
def animate_glyphs(scatter, sequence_length=None, add=True, interval=200): """Animate scatter or quiver by adding a slider and play button. :param scatter: scatter or quiver object :param sequence_length: If sequence_length is None we try try our best to figure out, in case we do it badly, you can tell us what it should be :param add: if True, add the widgets to the container, else return a HBox with the slider and play button :param interval: interval in msec between each frame :return: """ if sequence_length is None: # get all non-None arrays values = [getattr(scatter, name) for name in "x y z vx vy vz".split()] values = [k for k in values if k is not None] # sort them such that the higest dim is first values.sort(key=lambda key: -len(key.shape)) sequence_length = values[0].shape[ 0] # assume this defines the sequence length fig = gcf() fig.animation = interval fig.animation_exponent = 1. play = ipywidgets.Play(min=0, max=sequence_length, interval=interval, value=0, step=1) slider = ipywidgets.IntSlider(min=0, max=play.max - 1) ipywidgets.jslink((play, 'value'), (slider, 'value')) ipywidgets.jslink((slider, 'value'), (scatter, 'sequence_index')) control = ipywidgets.HBox([play, slider]) if add: current.container.children += (control, ) else: return control
def show_ipygany(plotter, return_viewer, height=None, width=None): """Show an ipygany scene.""" # convert each mesh in the plotter to an ipygany scene actors = plotter.renderer._actors meshes = [] for actor in actors.values(): ipygany_obj = ipygany_block_from_actor(actor) if ipygany_obj is not None: meshes.append(ipygany_obj) bc_color = color_float_to_hex(*plotter.background_color) scene = Scene(meshes, background_color=bc_color, camera=ipygany_camera_from_plotter(plotter)) # optionally size of the plotter if height is not None: scene.layout.height = f'{height}' if width is not None: scene.layout.width = f'{width}' cbar = None if len(plotter.scalar_bars): for mesh in meshes: if isinstance(mesh, ipygany.IsoColor): cbar = ipygany.ColorBar(mesh) colored_mesh = mesh break # Simply return the scene if return_viewer: return scene if cbar is not None: # Colormap choice widget colormap_dd = Dropdown(options=colormaps, description='Colormap:') jslink((colored_mesh, 'colormap'), (colormap_dd, 'index')) # sensible colorbar maximum width, or else it looks bad when # window is large. cbar.layout.max_width = '500px' cbar.layout.min_height = '50px' # stop from getting squished # cbar.layout.height = '20%' # stop from getting squished # cbar.layout.max_height = '' # Create a slider that will dynamically change the boundaries of the colormap # colormap_slider_range = FloatRangeSlider(value=[height_min, height_max], # min=height_min, max=height_max, # step=(height_max - height_min) / 100.) # jslink((colored_mesh, 'range'), (colormap_slider_range, 'value')) # create app title = HTML(value=f'<h3>{list(plotter.scalar_bars.keys())[0]}</h3>') legend = VBox((title, colormap_dd, cbar)) scene = AppLayout(center=scene, footer=legend, pane_heights=[0, 0, '150px']) display.display_html(scene)
def lasso_min_delay_widget(self): widget = widgets.IntSlider(value=self.lasso_min_delay, min=0, max=max(100, self.lasso_min_delay), step=5) widgets.jslink((self, 'lasso_min_delay'), (widget, 'value')) return with_left_label('Lasso min delay', widget)
def show_dem3d(self, dem): nr, nc = len(dem.y), len(dem.x) triangle_indices = np.empty((nr - 1, nc - 1, 2, 3), dtype='uint32') r = np.arange(nr * nc, dtype='uint32').reshape(nr, nc) triangle_indices[:, :, 0, 0] = r[:-1, :-1] triangle_indices[:, :, 1, 0] = r[:-1, 1:] triangle_indices[:, :, 0, 1] = r[:-1, 1:] triangle_indices[:, :, 1, 1] = r[1:, 1:] triangle_indices[:, :, :, 2] = r[1:, :-1, None] triangle_indices.shape = (-1, 3) height_component = Component(name='value', array=self.alt) mesh = PolyMesh(vertices=self.vertices, triangle_indices=triangle_indices, data={'height': [height_component]}) colored_mesh = IsoColor(mesh, input='height', min=np.min(self.alt), max=np.max(self.alt)) warped_mesh = Warp(colored_mesh, input=(0, 0, ('height', 'value')), factor=0) warp_slider = FloatSlider(min=0, max=10, value=0, description='Vertical exaggeration', style={'description_width': 'initial'}) jslink((warped_mesh, 'factor'), (warp_slider, 'value')) self.dem3d.clear_output() with self.dem3d: display(VBox((Scene([warped_mesh]), warp_slider)))
def __init__( self, first, last, ): play = widgets.Play( # interval=10, value=0, min=first, max=last, step=1, description="Press play", disabled=False, continuous_updata=1, ) slider = widgets.IntSlider() widgets.jslink((play, "value"), (slider, "value")) hbox = widgets.HBox([play, slider]) display(hbox) fig, ax = plt.subplots(1, 1, figsize=(9, 6)) while True: print(play.value) time.sleep(2) ax.plot(play.value) fig.canvas.draw_idle()
def __init__(self): self.prev = MapBtn("fas fa-chevron-left", value=-1) self.next = MapBtn("fas fa-chevron-right", value=1) self.select = sw.Select( dense=True, label=cm.widget.planet.select.label, v_model=None, items=[], prepend_icon="mdi-pound", clearable=True, ) super().__init__( v_model=None, align_center=True, row=True, class_="ma-1", children=[self.prev, self.select, self.next], ) # disable by default self.disable() # js behaviour jslink((self, "v_model"), (self.select, "v_model")) self.prev.on_event("click", self._on_click) self.next.on_event("click", self._on_click)
def SlideShower(folder, frame_duration=800): slides = list([open(os.path.join(folder,s), 'rb').read() for s in natural_sort(os.listdir(folder))]) x, y = _get_png_info(slides[0]) img = widgets.Image(value=slides[0], width=x, height=y) def on_frame(change): n = change['new'] img.value = slides[n] play = widgets.Play( value=0, min=0, max=len(slides), step=1, interval=frame_duration, disabled=False ) slider = widgets.IntSlider( value=0, min=0, max=len(slides)-1, step=1 ) slider.observe(on_frame, names='value') widgets.jslink((play, 'value'), (slider, 'value')) box = widgets.VBox([img, widgets.HBox([play, slider])]) return box
def AnimateList(lst, play=False, interval=200): slider = widgets.IntSlider(min=0, max=len(lst) - 1, step=1, value=0) if play: play_widjet = widgets.Play(interval=interval) widgets.jslink((play_widjet, 'value'), (slider, 'value')) display(play_widjet) return interact(StepSlice, lst=fixed(lst), step=slider)
def __init__(self, name): self.dirname = os.path.join(name, "") odtfile = max(glob.iglob("{}*.odt".format(self.dirname)), key=os.path.getctime) self.dt = oommfodt.OOMMFodt(odtfile).df self.time = self.dt["t"].as_matrix() / 1e-12 self.slider = ipywidgets.IntSlider( value=self.time[0], min=self.time[0], max=self.time[-1], step=self.time[1] - self.time[0], description="t (ps):", readout=True, layout=ipywidgets.Layout(width="100%"), continuous_update=False) self.select = ipywidgets.Select(options=list(self.dt.columns.values), description="Output:") self.play = ipywidgets.Play(value=self.time[0], min=self.time[0], max=self.time[-1], step=self.time[1] - self.time[0]) ipywidgets.jslink((self.play, "value"), (self.slider, "value")) self.slider.observe(self.update_output_slider) self.select.observe(self.update_output_slider) self.out = ipywidgets.Output(layout=ipywidgets.Layout(width="300%")) self.update_output_slider(None)
def _get_display_properties(self): props = {} coloring = Coloring( self.dataset, colormaps=list(colormaps.keys()), default_colormap='Viridis', canvas_callback_var=self._redraw_canvas, canvas_callback_range=self.components['canvas'].reset_isocolor_limits, canvas_callback_scale=self._set_color_scale, ) widgets.link( (coloring.colormaps_dropdown, 'index'), (self.components['canvas'].isocolor, 'colormap') ) widgets.link((coloring.min_input, 'value'), (self.components['canvas'].isocolor, 'min')) widgets.link((coloring.max_input, 'value'), (self.components['canvas'].isocolor, 'max')) props['coloring'] = coloring colorbar = GanyColorbar(self.dataset, isocolor=self.components['canvas'].isocolor) props['colobar'] = colorbar vert_exag = VerticalExaggeration(self.dataset, canvas_callback=self._update_warp_factor) props['vertical_exaggeration'] = vert_exag bgcolor = BackgroundColor(self.dataset) widgets.link((bgcolor.picker, 'value'), (self.canvas, 'background_color')) widgets.jslink((bgcolor.picker, 'value'), (self.canvas, 'background_color')) props['background_color'] = bgcolor return props
def setup(self): nsteps = self.dataset._widgets.nsteps self.label = widgets.Label(self.dataset._widgets.current_time_fmt) self.label.layout = widgets.Layout(width='150px') self.slider = widgets.IntSlider(value=0, min=0, max=nsteps - 1, readout=False) self.slider.layout = widgets.Layout(width='auto', flex='3 1 0%') self.slider.observe(self._update_step, names='value') self.play = widgets.Play(value=0, min=0, max=nsteps - 1, interval=100) self.play_speed = widgets.IntSlider(value=30, min=0, max=50, readout=False) self.play_speed.layout = widgets.Layout(width='auto', flex='1 1 0%') self.play_speed.observe(self._update_play_speed, names='value') widgets.jslink((self.play, 'value'), (self.slider, 'value')) return widgets.HBox( [ self.play, widgets.Label('slow/fast: '), self.play_speed, widgets.Label('steps: '), self.slider, self.label, ], layout=widgets.Layout(width='100%'), )
def showSlice(filePath): image = sitk.ReadImage(filePath) img = sitk.GetArrayFromImage(image) zSlice = img[1, :, :] pl = figure(plot_width=400, plot_height=400, x_range=(0, 10), y_range=(0, 10)) slicer = pl.image(image=[zSlice], x=[0], y=[0], dw=[10], dh=[10]) def update(z): zSlicer = img[z, :, :] slicer.data_source.data['image'] = [zSlicer] push_notebook() show(pl, notebook_handle=True) play = widgets.Play(value=50, min=0, max=154, step=1, description="Press play", disabled=False) slider = widgets.IntSlider() widgets.jslink((play, 'value'), (slider, 'value')) interact(update, z=play) display(slider)
def show_result(lim=20): """Display filter result.""" global error x, m, data, error = _load() fig = Figure(lim=lim) fig.hline.opacities = [0.75] estline = fig.add_line([], [], 'go') def run(i, tail=True, sleep=0): if i == 0: fig.clear_tail() xi = x[:, i] mi = m[:, i] di = data[i] fig.update(xi, tail=tail, data=di) estline.x = [mi[0]] estline.y = [mi[1]] time.sleep(sleep) play = Play(value=0, min=0, max=1000, step=1) playbar = IntSlider(value=0, min=0, max=1000) jslink((play, 'value'), (playbar, 'value')) w = interactive(run, i=play, tail=True, sleep=_spd_sld()) display(HBox((fig.fig, VBox([w, playbar]))))
def animate_list(lst, play=False, navigation=True, interval=200): slider = widgets.IntSlider(min=0, max=len(lst) - 1, step=1, value=0) if navigation: prev_button = widgets.Button( description='Prev', disabled=False, ) next_button = widgets.Button( description='Next', disabled=False, ) def increment_value(arg): slider.value += 1 def decrement_value(arg): slider.value -= 1 prev_button.on_click(decrement_value) next_button.on_click(increment_value) if play: play_widget = widgets.Play(interval=interval) widgets.jslink((play_widget, 'value'), (slider, 'value')) if play or navigation: if play and navigation: display(widgets.HBox([play_widget, prev_button, next_button])) elif play: display(play_widjet) elif navigation: display(widgets.HBox([prev_button, next_button])) return interact(step_slice, lst=fixed(lst), step=slider)
def height_widget(self): widget = widgets.IntSlider(value=self.height, min=128, max=max(1280, self.height + 64), step=32) widgets.jslink((self, 'height'), (widget, 'value')) return with_left_label('Height', widget)
def on_select_to_plot(self, change): """Call-back function for plotting a 3D visualisaiton of the segmentation""" #if the selected file has changed, import image, segmentation and global mask and plot if change['new'] != change['old']: print('new: ' + str(change['new'])) print('old: ' + str(change['old'])) image = skimage.io.imread(self.folder_name + '/' + self.select_file_to_plot.value, plugin='tifffile') image2 = skimage.io.imread( self.folder_name + '/' + os.path.splitext(self.select_file_to_plot.value)[0] + '_label.tif', plugin='tifffile') image3 = skimage.io.imread( self.folder_name + '/' + os.path.splitext(self.select_file_to_plot.value)[0] + '_region.tif', plugin='tifffile') #create ipyvolume figure ipv.figure() volume_image = ipv.volshow(image[0, :, :, :, 1], extent=[[0, 1024], [0, 1024], [-20, 20]], level=[0.3, 0.2, 0.2], opacity=[0.2, 0, 0]) volume_seg = ipv.plot_isosurface(np.swapaxes(image2 > 0, 0, 2), level=0.5, controls=True, color='green', extent=[[0, 1024], [0, 1024], [-20, 20]]) volume_reg = ipv.volshow(image3, extent=[[0, 1024], [0, 1024], [-20, 20]], level=[0.3, 0.2, 1], opacity=[0.0, 0, 0.5]) volume_reg.brightness = 10 volume_image.brightness = 10 volume_image.opacity = 100 ipv.xyzlim(0, 1024) ipv.zlim(-500, 500) ipv.style.background_color('black') #create additional controls to show/hide segmentation color = ColorPicker(description='Segmentation color') visible = ipw.Checkbox() jslink((volume_seg, 'color'), (color, 'value')) jslink((volume_seg, 'visible'), (visible, 'value')) ipv.show() with self.out: clear_output(wait=True) display(VBox([ipv.gcc(), color, visible])) viewer = napari.Viewer(ndisplay=3) viewer.add_image(image, colormap='red') viewer.add_image(image2, colormap='green', blending='additive') viewer.add_image(image3, colormap='blue', blending='additive')
def lasso_min_dist_widget(self): widget = widgets.IntSlider(value=self.lasso_min_dist, min=0, max=max(32, self.lasso_min_dist), step=2) widgets.jslink((self, 'lasso_min_dist'), (widget, 'value')) return with_left_label('Lasso min dist', widget)
def __init__(self, label="Date", **kwargs): date_picker = v.DatePicker(no_title=True, v_model=None, scrollable=True) date_text = v.TextField(v_model=None, label=label, hint="YYYY-MM-DD format", persistent_hint=True, prepend_icon="event", readonly=True, v_on='menuData.on') menu = v.Menu(transition="scale-transition", offset_y=True, v_slots=[{ 'name': 'activator', 'variable': 'menuData', 'children': date_text, }], children=[date_picker]) super().__init__(v_model=None, row=True, class_='pa-5', align_center=True, children=[v.Flex(xs10=True, children=[menu])], **kwargs) jslink((date_picker, 'v_model'), (date_text, 'v_model')) jslink((date_picker, 'v_model'), (self, 'v_model'))
def figure(key=None, width=400, height=500, lighting=True, controls=True, debug=False): """Create a new figure (if no key is given) or return the figure associated with key :param key: Python object that identifies this figure :param width: pixel width of WebGL canvas :param height: .. height .. :param lighting: use lighting or not :param controls: show controls or not :param debug: show debug buttons or not :return: """ if key is not None and key in current.figures: current.figure = current.figures[key] current.container = current.containers[key] else: current.figure = volume.VolumeRendererThree(data=None) current.container = ipywidgets.VBox() current.container.children = [current.figure] if key is not None: current.figures[key] = current.figure current.containers[key] = current.container if controls: stereo = ipywidgets.ToggleButton(value=current.figure.stereo, description='stereo', icon='eye') fullscreen = ipywidgets.ToggleButton(value=current.figure.stereo, description='fullscreen', icon='arrows-alt') l1 = ipywidgets.jslink((current.figure, 'stereo'), (stereo, 'value')) l2 = ipywidgets.jslink((current.figure, 'fullscreen'), (fullscreen, 'value')) current.container.children += (ipywidgets.HBox([stereo, fullscreen]),) if debug: show = ipywidgets.ToggleButtons(options=["Volume", "Back", "Front"]) current.container.children += (show,) ipywidgets.jslink((current.figure, 'show'), (show, 'value')) return current.figure
def __init__(self): self.prev = v.Btn(_metadata={'increm': -1}, x_small=True, class_='ml-2 mr-2', color=sc.secondary, children=[ v.Icon(children=['mdi-chevron-left']), cm.dynamic_select.prev ]) self.next = v.Btn(_metadata={'increm': 1}, x_small=True, class_='ml-2 mr-2', color=sc.secondary, children=[ cm.dynamic_select.next, v.Icon(children=['mdi-chevron-right']) ]) self.select = v.Select(dense=True, label=cm.dynamic_select.label, v_model=None) super().__init__(v_model=None, align_center=True, row=True, class_='ma-1', children=[self.prev, self.select, self.next]) # js behaviour jslink((self, 'v_model'), (self.select, 'v_model')) self.prev.on_event('click', self._on_click) self.next.on_event('click', self._on_click)
def __init__(self, layer, map): self.layer = layer self.map = map name = widgets.Text( value=layer.name, placeholder="Layer name", layout=widgets.Layout(min_width="4em", max_width="12em"), ) widgets.jslink((name, "value"), (layer, "name")) self._widgets["name"] = name move_up = widgets.Button(description=u"↑", tooltip="Move layer up", layout=button_layout) move_up.on_click(self.move_up) self._widgets["move_up"] = move_up move_down = widgets.Button(description=u"↓", tooltip="Move layer down", layout=button_layout) move_down.on_click(self.move_down) self._widgets["move_down"] = move_down remove = widgets.Button(description=u"✖︎", tooltip="Remove layer", layout=button_layout) remove.on_click(self.remove) self._widgets["remove"] = remove super(LayerControllerRow, self).__init__(self._make_children()) self.layout.overflow = "initial"
def interactive_plot(): if part.dim != 2: print('only works in 2D') return l = widgets.Layout(width='150px') step_text = widgets.BoundedIntText(min=0, max=part.num_frames - 1, value=0, layout=l) step_slider = widgets.IntSlider(min=0, max=part.num_frames - 1, value=0, readout=False, continuous_update=False, layout=l) play_button = widgets.Play(min=0, max=part.num_frames - 1, step=1, interval=500, layout=l) widgets.jslink((step_text, 'value'), (step_slider, 'value')) widgets.jslink((step_text, 'value'), (play_button, 'value')) img = widgets.interactive_output(draw, {'s': step_text}) wid = widgets.HBox( [widgets.VBox([step_text, step_slider, play_button]), img]) display(wid)
def _create_play_bar(self, num_iterations: int) -> widgets.Widget: """Create play bar widget over iterations. Args: num_iterations (int): length of the play bar Returns: widgets.Widget: play bar widget """ play = widgets.Play( value=1, min=1, max=num_iterations, step=1, interval=400, disabled=False, ) slider = widgets.IntSlider(1, 1, num_iterations) # Linking slider and play bar values in javascript widgets.jslink((play, "value"), (slider, "value")) self.widgets["iteration"] = slider return widgets.HBox([play, slider])
def animation(self, t, v, interval, duration, a_step=10, a_interval=100, a_duration=10): xs = LinearScale() ys = LinearScale() line = Lines(x=t[:interval], y=v[:, :interval], scales={'x': xs, 'y': ys}) xax = Axis(scale=xs, label='x', grid_lines='solid') yax = Axis(scale=ys, orientation='vertical', tick_format='0.2f', label='y', grid_lines='solid') fig = Figure(marks=[line], axes=[xax, yax], animation_duration=a_duration) def on_value_change(change): line.x = t[change['new']:interval + change['new']] line.y = v[:, change['new']:interval + change['new']] play = widgets.Play( interval=a_interval, value=0, min=0, max=duration, step=a_step, description="Press play", disabled=False ) slider = widgets.IntSlider(min=0, max=duration) widgets.jslink((play, 'value'), (slider, 'value')) slider.observe(on_value_change, names='value') return play, slider, fig
def __init__(self, label="Table file"): self.fileInput = FileInput(['.csv', '.txt'], label=label) self.IdSelect = v.Select(_metadata={'name': 'id_column'}, items=[], label='Id', v_model=None) self.LngSelect = v.Select(_metadata={'name': 'lng_column'}, items=[], label='Longitude', v_model=None) self.LatSelect = v.Select(_metadata={'name': 'lat_column'}, items=[], label='Latitude', v_model=None) super().__init__(v_model=self.default_v_model, children=[ self.fileInput, self.IdSelect, self.LngSelect, self.LatSelect ]) # link the dropdowns jslink((self.IdSelect, 'items'), (self.LngSelect, 'items')) jslink((self.IdSelect, 'items'), (self.LatSelect, 'items')) # link the widget with v_model self.fileInput.observe(self._on_file_input_change, 'v_model') self.IdSelect.observe(self._on_select_change, 'v_model') self.LngSelect.observe(self._on_select_change, 'v_model') self.LatSelect.observe(self._on_select_change, 'v_model')
def show(): max_ = max_iter * n_scenes i = IntSlider(value=0, min=0, max=max_, continuous_update=False) play = Play(interval=2000, value=0, min=0, max=max_, step=1) jslink((play, 'value'), (i, 'value')) output = interactive_output(plot, dict(i=i)) display(play, output)
def _frame_folder(self, nframes): playable = bool(nframes <= 1) flims = dict(min=0, max=nframes-1, step=1, value=0) control = Button(description=' Animate', icon='play') content = _ListDict([ ('playing', Play(disabled=playable, **flims)), ('scn_frame', IntSlider(description='Frame', **flims))]) def _scn_frame(c): for scn in self.active(): scn.frame_idx = c.new content['scn_frame'].observe(_scn_frame, names='value') content['playing'].active = False jslink((content['playing'], 'value'), (content['scn_frame'], 'value')) folder = Folder(control, content) return folder
def plot_with_pythreejs(cloud, **kwargs): if ipywidgets is None: raise ImportError("ipywidgets is needed for plotting with pythreejs backend.") if pythreejs is None: raise ImportError("pythreejs is needed for plotting with pythreejs backend.") if display is None: raise ImportError("IPython is needed for plotting with pythreejs backend.") colors = get_colors(cloud, kwargs["use_as_color"], kwargs["cmap"]) ptp = cloud.xyz.ptp() children = [] widgets = [] if kwargs["mesh"]: raise NotImplementedError("Plotting mesh geometry with pythreejs backend is not supported yet.") if kwargs["polylines"]: lines = get_polylines_pythreejs(kwargs["polylines"]) children.extend(lines) points = get_pointcloud_pythreejs(cloud.xyz, colors) children.append(points) initial_point_size = kwargs["initial_point_size"] or ptp / 10 size = ipywidgets.FloatSlider( value=initial_point_size, min=0.0, max=initial_point_size * 10, step=initial_point_size / 100) ipywidgets.jslink((size, 'value'), (points.material, 'size')) widgets.append(ipywidgets.Label('Point size:')) widgets.append(size) if kwargs["scene"]: kwargs["scene"].children = [points] + list(kwargs["scene"].children) else: camera = get_camera_pythreejs(cloud.centroid, cloud.xyz, kwargs["width"], kwargs["height"]) children.append(camera) controls = [get_orbit_controls(camera, cloud.centroid)] scene = pythreejs.Scene(children=children) renderer = pythreejs.Renderer( scene=scene, camera=camera, controls=controls, width=kwargs["width"], height=kwargs["height"]) display(renderer) color = ipywidgets.ColorPicker(value=kwargs["background"]) ipywidgets.jslink((color, 'value'), (scene, 'background')) widgets.append(ipywidgets.Label('Background color:')) widgets.append(color) display(ipywidgets.HBox(children=widgets)) return scene if kwargs["return_scene"] else None