def panel(self, debug=False): title = pn.pane.Markdown('# Search MAST for Moving Targets') row1 = pn.Row(self.obj_name, self.id_type) row2 = pn.Row(self.start_time, self.stop_time, self.time_step) button_row = pn.Row(self.param['ephem_button'], self.param['tap_button']) output_tabs = pn.Tabs( ('Ephemerides', pn.Column(self.eph_col_choice, self.get_ephem)), ('MAST Results', pn.Column(self.mast_col_choice, self.get_mast)), ('MAST Plot', self.mast_figure)) if debug: output_tabs.append(('Debug', self.fetch_stcs)) gspec = pn.GridSpec(width=800, height=400) gspec[:1, :3] = title gspec[2, :3] = row1 gspec[3, :3] = row2 gspec[4, :3] = button_row gspec[5, :3] = output_tabs ''' mypanel = pn.Column(title, pn.layout.Divider(), row1, row2, button_row, output_tabs)''' return gspec
def dashboard_column(plots, shared_slider=False): # Generate a Panel dashboard from a list of interactive plots # Create a Panel object to host our plots app = pn.GridSpec(sizing_mode='stretch_both') # Arrange plots in a column column = pn.Column(*plots) # Add plots and sliders to Panel app if shared_slider: # Link all the sliders to one slider # TODO: Add check for whether sliders can be linked slider1 = column[0][1][0] for plot in column[1:]: slider = plot[1][0] slider1.link(slider, value='value') # Append all the plots to the app (using 3/4 of the horizontal space) for i, plot in enumerate(column): app[i, 0:4] = plot[0] # Add the linked slider (using the last 1/4 of the horizontal space) app[0, 4] = slider1 else: # Append whole column (with individual sliders) to the app app[0, 0] = column return app
def plot_without_asr_dipdip(self): if self.plot_check_asr_dipdip_btn.clicks == 0: return # Insert results in grid. gspec = pn.GridSpec(sizing_mode='scale_width') asr_plotter = self.ddb.anacompare_asr( asr_list=(0, 2), chneut_list=(1, ), dipdip=1, lo_to_splitting=self.lo_to_splitting, nqsmall=self.nqsmall, ndivsm=self.ndivsm, dos_method=self.dos_method, ngqpt=None, verbose=self.verbose, mpi_procs=self.mpi_procs) gspec[0, :1] = asr_plotter.plot(**self.fig_kwargs) dipdip_plotter = self.ddb.anacompare_dipdip( chneut_list=(1, ), asr=2, lo_to_splitting=self.lo_to_splitting, nqsmall=self.nqsmall, ndivsm=self.ndivsm, dos_method=self.dos_method, ngqpt=None, verbose=self.verbose, mpi_procs=self.mpi_procs) gspec[1, :1] = dipdip_plotter.plot(**self.fig_kwargs) return gspec
def visualize(self): daily_plot_cols_labels = {"INFECTED": "Infected", "RECOVERED": "Recovered", "DEAD": "dead"} change_plot_cols_labels = { "num_recovered_cases": "# newly recovered", "num_deceased_cases": "# of new deaths", "num_new_cases": "# of new cases" } mobility_plot_cols_labels = { "num_state_changed": "# of residents moved" # NOTE: Only people moving is considered a state change as of today } gspec = pn.GridSpec(width=975, margin=0, sizing_mode="stretch_both") mobility_plot = self.curve.visualize_time_series(mobility_plot_cols_labels.keys(), rename_cols=mobility_plot_cols_labels, options=opts(title="∆ in number of residents moved", ylabel="Periodic change", height=300, show_legend=False)) daily_plot = self.curve.visualize_time_series(daily_plot_cols_labels.keys(), rename_cols=daily_plot_cols_labels, options=opts(ylabel="Total as of date")) change_plot = self.curve.visualize_time_series(change_plot_cols_labels.keys(), rename_cols=change_plot_cols_labels, options=opts(ylabel="Periodic change in metric")) gspec[0, 0:2] = self.city.visualize() gspec[0, 2:5] = mobility_plot gspec[0, 5] = self.curve.visualize_recent_residents_moved(opts(width=100, title="")) gspec[1, :3] = daily_plot gspec[1, 3:] = change_plot return gspec
def _create_app(): player_select_widget = pn.widgets.Select( options=list(_get_epl_strikers_df()["player_name"].unique()), value="Bruno Fernandes", min_width=1600, max_width=1800, ) # assign css class to achieve better design granularity player_select_row = pn.Row( pn.pane.Str("Choose A Player for Analysis:", sizing_mode="fixed"), player_select_widget, align="center", css_classes=["player_select_row"], ) # Panel HTML elements can take a 'style' parameter directly. # You could alternatively assign a css class as above and include the css code in raw_css title_html_pane = pn.pane.HTML( """ <h1>Panel Soccer Analytics Dashboard</h1> """, style={ "color": "white", "width": "90%", "text-align": "center" }, ) # bind the 'player_select_widget' to our functions above bound_player_png_image_pane = pn.bind(_get_and_display_player_image, player=player_select_widget) plot_horizontal_bar_pane = pn.bind(_plot_horizontal_bar, player=player_select_widget) bound_plotly_line_plot_pane = pn.bind(_plot_line_plot, player=player_select_widget) bound_plotly_scatter_plot_pane = pn.bind(_plot_scatter_plot, player=player_select_widget) # create a new gridspec with 14 columns and 12 rows gspec = pn.GridSpec(ncols=14, nrows=12, sizing_mode="stretch_both", css_classes=["gspec_container"]) # place application elements in the grid, using pn.Spacer() for improved layout spacing and # control gspec[0, :14] = title_html_pane gspec[1, :14] = player_select_row gspec[3:6, 1:3] = bound_player_png_image_pane gspec[2:7, 3] = pn.Spacer() gspec[2:7, 4:14] = plot_horizontal_bar_pane gspec[7:10, 0:7] = bound_plotly_line_plot_pane gspec[7:10, 7:14] = bound_plotly_scatter_plot_pane gspec[11, 0:14] = pn.Row(pn.Spacer(), CSS_PANE) return gspec
def panel(self): """The image viewer as a panel to display. """ self._set_css() # Widget to show image informations. info_widget = self._get_image_info info_container = pn.Column(pn.pane.Markdown("## Informations"), info_widget) # Widget with parameter widgets to control image viewer. parameters_widget = pn.Param( self.param, show_name=False, parameters=self.active_param_widgets, widgets=self.param_widgets, sizing_mode="scale_both", ) parameters_widget = pn.WidgetBox(parameters_widget) parameters_container = pn.Column( pn.pane.Markdown("## Viewer Configurations"), parameters_widget ) # Assemble informations and parameters widgets. tools_widget = pn.Column(info_container, parameters_container) # Image container image_container = pn.Row(self._get_fig) # Log container log_container = self.log.panel(height=200) # Viewer layout main_pane_args = {} main_pane_args["css_classes"] = [f"viewer-{self.viewer_id}"] main_pane_args["margin"] = 0 if self.width and self.height: main_pane_args["width"] = self.width main_pane_args["height"] = self.height elif self.width: main_pane_args["width"] = self.width main_pane_args["sizing_mode"] = "stretch_height" elif self.height: main_pane_args["height"] = self.height main_pane_args["sizing_mode"] = "stretch_width" else: main_pane_args["sizing_mode"] = "scale_both" gspec = pn.GridSpec(**main_pane_args) gspec[0, :1] = tools_widget gspec[0, 1:20] = image_container # gspec[1, :20] = viewer.drawer.panel() gspec[1, :20] = log_container return gspec
def view(self): spatial = self._get_spatial_distribution(self.gene, self.exact) fpkm = self._get_fpkm(self.gene, self.exact) expression = self._get_expression(self.gene, self.exact) gspec = pn.GridSpec(width=1000, height=800) gspec[0, 0:6] = spatial gspec[1, 0:2] = fpkm gspec[1, 2:6] = expression return gspec
def plots_as_matrix(plots, ncols, nrows, width=500, height=500): """Takes a list of plots and puts them into a matrix""" plot_matrix = pn.GridSpec(ncols=ncols, nrows=nrows, width=width, height=height) for index, plot in enumerate(plots): row_pos = index//ncols col_pos = index%ncols if row_pos >= nrows: break else: plot_matrix[row_pos, col_pos] = plot return plot_matrix
def build_gui(self): """All filters used below need to have two functions get_selection and update_with_mask.""" data_selection = getattr(self.dataset, self.DESCRIPTOR_DATA)[self.columns] self.generate_filters(data_selection) # put the images in the grid self.gui = pn.GridSpec(ncols=self.n_cols, nrows=self.n_rows, width=self.width, height=self.height) for index, gui_filter in enumerate(self.filters): self.gui[index//self.n_cols, index%self.n_cols] = gui_filter.show() # hook all control elements to the update functions for single_filter in self.filters: single_filter.register_callback(self.update_plots)
def getApp(doc): os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true" baseVizElement = getBaseVizElement(doc.session_context.request.headers["viz-element-id"]) init = True viz = baseVizElement._vizApp gspec = pn.GridSpec(sizing_mode='stretch_both', max_height=800) gspec[0, :3] = pn.Row(pn.Row(viz.param, parameters=['update']),viz.view) gspec[1, :3] = pn.Row(viz.viewDataFrame) gspec.server_doc(doc)
def report_dboard(): input_data = pd.DataFrame.from_dict({ "longitude": [-0.155, 0.2795, -0.12344], "latitude": [51.5229, 51.5560, 51.5046313], }) interactive_map = maps.ExampleMap(input_data) gspec = pn.GridSpec(sizing_mode="stretch_both") gspec[0, 0] = interactive_map.param gspec[1, 0] = interactive_map.view return gspec
def layout(server_name): global server, e, valid_stdnames global progressbar global wds_menu, wds_date, wstdname_menu, wstdname_date global dsnames, dsmap, df_dsmap wstdname_date = pn.widgets.DateRangeSlider( start=datetime.datetime(2011, 1, 1), end=utcnow, value=(utcnow - datetime.timedelta(days=14), utcnow), ) wds_date = pn.widgets.DateRangeSlider( name="Limits for the timeseries plot", start=datetime.datetime(2011, 1, 1), end=utcnow, value=(wstdname_date.value_start, wstdname_date.value_end), ) progressbar = pn.indicators.Progress( name="Checking the variables available for this server", bar_color="info", value=0, width=200, ) valid_stdnames, server, e = get_valid_stdnames(server_name) wstdname_menu = f_wstdname_menu(valid_stdnames) wds_menu = f_wds_menu() wstdname_menu.param.watch(update_wds_menu, "value") wstdname_date.param.watch(update_wds_date, "value") dyndsmap = create_dyndsmap() dyntseries = create_dyntseries() gspec = pn.GridSpec(sizing_mode="stretch_both", max_height=800) gspec[0, 0] = OSM() * dyndsmap gspec[0, 1] = pn.WidgetBox( "## ERDDAP timeseries explorer", wstdname_menu, wstdname_date, wds_menu, wds_date, ) gspec[1, :] = dyntseries display(gspec)
def make_view(self): state = fetch_all_models_metrics_for_feature_on_dataset(self.protected_feature, self.ad_category) total_records_count = reduce(lambda acc, model_stats: model_stats["total_count"] + acc, state.values(), 0) plotted_records_count = reduce(lambda acc, model_stats: model_stats["plot_count"] + acc, state.values(), 0) num_models = len(state.values()) html_stats_div = lambda s: f"""<p style="text-align: center; margin-top: 3rem;">{s}</p>""" stats_text = html_stats_div(f"{self.ad_category} ad category has {plotted_records_count / num_models:.2f} records of {total_records_count / num_models:.0f} records in total on an average") gspec = pn.GridSpec(sizing_mode="stretch_both", align="center") # background="gray" gspec[:15, :2] = chart_for_metric(state, FPR, fpr_opts) gspec[:15, 2:4] = chart_for_metric(state, EOD, gfm_opts) gspec[:15, 4:6] = chart_for_metric(state, AOD, gfm_opts) gspec[15, :] = stats_text return gspec
def plot_model_evaluation( model, X_train, y_train, X_test, y_test, target_names=None, feature_names=None, normalize: bool = False, resolution: int = 100, stacked: bool = False, embedding: np.ndarray = None, ): import panel as pn y_pred_test = model.predict(X_test) metrics = plot_classification_report(y=y_test, y_pred=y_pred_test, target_names=target_names) conf_mat = plot_confussion_matrix(y_test=y_test, y_pred=y_pred_test, target_names=target_names, normalize=normalize) bounds = plot_decision_boundaries( X_train=X_train, y_train=y_train, y_pred_train=model.predict(X_train), X_test=X_test, y_test=y_test, y_pred_test=model.predict(X_test), resolution=resolution, embedding=embedding, ) # features = plot_feature_importances( # model=model, target_names=target_names, feature_names=feature_names, stacked=stacked # ) gspec = pn.GridSpec(min_height=700, height=700, max_height=1200, min_width=750, max_width=1980, width=750) gspec[0, 0] = bounds gspec[1, 1] = metrics gspec[1, 0] = pn.pane.HTML(str(model), margin=0) gspec[0, 1] = conf_mat # gspec[3:5, :] = features return gspec
def _create_grids(self): """ Creates a 2x2 grid of the prior and posterior predictive checks for min, max, mean and std function. Sets: -------- _grids A Dict of pn.GridSpec objects: {<var_name>:{<space>:pn.GridSpec}} """ for var in self._pred_checks: if self._data.is_observed_variable(var): c_min = PredictiveChecksCell(var, self._mode, self._ic, "min") c_max = PredictiveChecksCell(var, self._mode, self._ic, "max") c_mean = PredictiveChecksCell(var, self._mode, self._ic, "mean") c_std = PredictiveChecksCell(var, self._mode, self._ic, "std") self._cells['min'] = c_min self._cells['max'] = c_max self._cells['mean'] = c_mean self._cells['std'] = c_std ##Add to grid cell_spaces = c_min.get_spaces() self._grids[var] = {} for space in cell_spaces: if space not in self._grids[var]: self._grids[var][space] = pn.GridSpec( sizing_mode='stretch_both') for row in [0, 1]: for i in [0, 1]: col = int( (MAX_NUM_OF_COLS_PER_ROW - 2. * COLS_PER_VAR) / 2.) start_point = (row, int(col + i * COLS_PER_VAR)) end_point = (row + 1, int(col + (i + 1) * COLS_PER_VAR)) if row == 0 and i == 0: self._grids[var][space][ start_point[0]:end_point[0], start_point[1]:end_point[1] ] = \ pn.Column(c_min.get_plot(space,add_info=False), width=220, height=220) elif row == 0 and i == 1: self._grids[var][space][ start_point[0]:end_point[0], start_point[1]:end_point[1] ] = \ pn.Column(c_max.get_plot(space,add_info=False), width=220, height=220) elif row == 1 and i == 0: self._grids[var][space][ start_point[0]:end_point[0], start_point[1]:end_point[1] ] = \ pn.Column(c_mean.get_plot(space,add_info=False), width=220, height=220) elif row == 1 and i == 1: self._grids[var][space][ start_point[0]:end_point[0], start_point[1]:end_point[1] ] = \ pn.Column(c_std.get_plot(space,add_info=False), width=220, height=220)
def _generate_annotations_tab(self): plot_width, plot_height = floor(self.width * 0.45), floor(self.height * 0.45) # mixing of classes mixing_matrix_classes_in_images = utils.calculate_mixing_matrix( getattr(self.dataset, self.DESCRIPTOR_DATA), self.IMAGE_IDENTIFIER_COL, self.ANNOTATON_LABEL_COL) self.class_mixing_matrix_plot = pn.Column( "<b>Class mixing</b>", heatmap(mixing_matrix_classes_in_images, "row_name", "col_name", "values", width=plot_width, height=plot_height), height=self.height) # number of object per image, stacked hist self.classes_for_objects_per_image_stacked_hist = pn.Column( "<b>Objects per Image</b>", stacked_hist(getattr(self.dataset, self.DESCRIPTOR_DATA), self.OBJECTS_PER_IMAGE_COL, self.ANNOTATON_LABEL_COL, "Objects per Image", width=plot_width, height=plot_height)) # categorical overview self.categorical_2d_histogram = categorical_2d_histogram_with_gui( getattr(self.dataset, self.DESCRIPTOR_DATA), category_cols=["label", "num_annotations", "width", "height"], hist_cols=[ "num_annotations", "area", "area_normalized", "area_square_root", "area_square_root_normalized", "bbox_ratio", "bbox_xmin", "bbox_xmax", "bbox_ymin", "bbox_ymax", "width", "height" ], height=self.height // 2, width=self.width // 2) # ratio distribution grid = pn.GridSpec(ncols=2, nrows=2, width=self.width, height=self.height, align="center") grid[0, 0] = self.class_mixing_matrix_plot grid[1, 0] = self.classes_for_objects_per_image_stacked_hist grid[:, 1] = pn.Column(self.categorical_2d_histogram, align="center") return grid
def combine_scatterplot_with_hists(select_x, select_y, select_color, xhist, yhist, scatterplot): select_buttons = column(select_x, select_y, select_color, sizing_mode='scale_width') gspec = pn.GridSpec(sizing_mode='stretch_both', max_width=2000, max_height=1500) gspec[0, 0:3] = xhist gspec[0, 3] = select_buttons gspec[1:3, 0:3] = scatterplot gspec[1:3, 3] = yhist return gspec
def plot_ifc(self): if self.plot_ifc_btn.clicks == 0: return ifc = self.ddb.anaget_ifc(asr=self.asr, chneut=self.chneut, dipdip=self.dipdip) # Insert results in grid. gspec = pn.GridSpec(sizing_mode='scale_width') gspec[0, :1] = ifc.plot_longitudinal_ifc(title="Longitudinal IFCs", show=False) gspec[1, :1] = ifc.plot_longitudinal_ifc_short_range( title="Longitudinal IFCs short range", show=False) gspec[2, :1] = ifc.plot_longitudinal_ifc_ewald( title="Longitudinal IFCs Ewald", show=False) return gspec
def __init__(self, parent): """Initialize single adsorbent row. :param parent: Adsorbates instance """ super().__init__() self.parent = parent self.btn_add = pw.Button(name='+', button_type='primary') self.btn_add.on_click(self.on_click_add) self.btn_remove = pw.Button(name='-', button_type='primary') self.btn_remove.on_click(self.on_click_remove) #self.inp_refcode = pw.TextInput(name='Refcode') #self.row = pn.Row(self.inp_name, self.btn_add, self.btn_remove) self.row = pn.GridSpec(height=50) self.row[0, 0:8] = self.inp_name self.row[0, 8] = self.btn_add self.row[0, 9] = self.btn_remove
def plot_phbands_and_phdos(self, event=None): """Compute phonon bands and ph-DOSes from DDB and plot the results.""" if self.plot_phbands_btn.clicks == 0: return #self.plot_phbands_btn.button_type = "warning" print("Computing phbands") with self.ddb.anaget_phbst_and_phdos_files( nqsmall=self.nqsmall, qppa=None, ndivsm=self.ndivsm, line_density=None, asr=self.asr, chneut=self.chneut, dipdip=self.dipdip, dos_method=self.dos_method, lo_to_splitting=self.lo_to_splitting, verbose=self.verbose, mpi_procs=self.mpi_procs, return_input=True) as g: phbst_file, phdos_file = g phbands, phdos = phbst_file.phbands, phdos_file.phdos print("Computing phbands completed") # Build grid gspec = pn.GridSpec(sizing_mode='scale_width') gspec[0, 0] = phbands.plot_with_phdos(phdos, units=self.units, **self.fig_kwargs) gspec[0, 1] = phdos_file.plot_pjdos_type(units=self.units, exchange_xy=True, **self.fig_kwargs) gspec[1, 0] = phdos_file.msqd_dos.plot(units=self.units, **self.fig_kwargs) temps = self.temp_range.value gspec[1, 1] = phdos.plot_harmonic_thermo(tstart=temps[0], tstop=temps[1], num=50, **self.fig_kwargs) #msqd_dos.plot_tensor(**self.fig_kwargs) #self.plot_phbands_btn.button_type = "primary" # Add HTML pane with input gspec[2, :] = pn.pane.HTML(g.input._repr_html_()) return gspec
def get_panel(self): """Return tabs with widgets to interact with the DDB file.""" tabs = pn.Tabs() app = tabs.append mocc = self.mocc gspec = pn.GridSpec(sizing_mode='scale_width') gspec[0, 0] = mocc.plot_memory_usage(show=False, title="Memory usage") gspec[0, 1] = mocc.plot_hist(show=False, title="Allocation histogram") gspec[1, :] = mocc.plot_peaks(maxlen=10, title="Memory peaks", show=False) maxlen = 50 df = mocc.get_peaks(maxlen=maxlen, as_dataframe=True) df.drop(columns=["locus", "line", "action", "ptr"], inplace=True) col = pn.Column(gspec, f"## DataFrame with the first {maxlen} peaks", _df(df), sizing_mode="scale_width") app(("Plots", col)) #app(("DataFrame", _df(mocc.dataframe))) hotdf = mocc.get_hotspots_dataframe() ax = hotdf.plot.pie(y='malloc_mb') import matplotlib fig = matplotlib.pyplot.gcf() app(("Hotspots", pn.Column( "### DataFrame with total memory allocated per Fortran file.", fig, _df(hotdf), sizing_mode='scale_width', ))) app(( "Intense", pn.Column( "### DataFrame with variables that are allocated/freed many times.", _df(mocc.get_intense_dataframe()), sizing_mode='scale_width'))) #retcode = memfile.find_memleaks() #app(("Memleaks", _df(mocc.find_memleaks()))) return tabs
def _init_view(self): info = """## Candle Stick Plot We can use a [*candlestick chart*](https://en.wikipedia.org/wiki/Candlestick_chart) to visualize the Open, High, Low, Close price data and histograms to visualize the Volume. Technically we use HoloViews [`Segments`]\ (https://holoviews.org/reference/elements/bokeh/Segments.html), [`Rectangles`]\ (https://holoviews.org/reference/elements/bokeh/Rectangles.html) and [`Histogram`]\ (https://holoviews.org/reference/elements/bokeh/Histogram.html) to create the plots and Panel [`GridSpec`](https://panel.holoviz.org/reference/layouts/GridSpec.html) to lay them out. """ self.view = pn.Column( pn.pane.Markdown(info), pn.GridSpec(sizing_mode="stretch_both", margin=0), sizing_mode="stretch_both", )
def generate_interface(): app = Application() handlers = pn.Param(app.param) # Analysis Page analysis_page = pn.GridSpec(height=850, width=1850, max_height=850, max_width=1850) analysis_page[0:8, 0:2] = handlers[1] analysis_page[0:10, 8:10] = handlers[2] analysis_page[8:9, 0:2] = handlers[3] analysis_page[9:10, 0:2] = handlers[4] analysis_page[0:5, 2:8] = app.performance_graph analysis_page[5:10, 2:8] = app.parameter_graph interface = pn.Tabs(('Analysis Page', analysis_page), ) return interface
def _create_grids(self): """ Creates one Cell object per variable. Cell object is the smallest visualization unit in the grid. Moreover, it creates one Panel GridSpec object per space. Sets: -------- _cells A Dict {<var_name>:Cell object}. _grids A Dict of pn.GridSpec objects: {<space>:pn.GridSpec} """ graph_grid_map = self._create_graph_grid_mapping() for row, map_data in graph_grid_map.items(): level = map_data[0] vars_list = map_data[1] level_previous = -1 if (row - 1) in graph_grid_map: level_previous = graph_grid_map[row - 1][0] if level != level_previous: col = int( (MAX_NUM_OF_COLS_PER_ROW - len(vars_list) * COLS_PER_VAR) / 2.) else: col = int((MAX_NUM_OF_COLS_PER_ROW - MAX_NUM_OF_VARS_PER_ROW * COLS_PER_VAR) / 2.) for i, var_name in enumerate(vars_list): start_point = (row, int(col + i * COLS_PER_VAR)) end_point = (row + 1, int(col + (i + 1) * COLS_PER_VAR)) #col_l = int(col_f + (i+1)*COLS_PER_VAR) grid_bgrd_col = level c = VariableCell(var_name, self._mode, self._ic) self._cells[var_name] = c ##Add to grid cell_spaces = c.get_spaces() for space in cell_spaces: if space not in self._spaces: self._spaces.append(space) if space not in self._grids: self._grids[space] = pn.GridSpec( sizing_mode='stretch_both') self._grids[space][ start_point[0]:end_point[0], start_point[1]:end_point[1] ] = pn.Column(c.get_plot(space), \ width=220, height=220) self._ic._num_cells = len(self._cells)
def create_candle_stick_with_histograms(data: pd.DataFrame) -> pn.GridSpec: """Returns a candle stick plot with volume distributions on the sides Args: data (pd.DataFrame): A dataframe with columns time, open, high, low, close and volume Returns: pn.GridSpec: A GridSpec containing the plots """ gridspec = pn.GridSpec(sizing_mode="stretch_both", min_height=600, margin=0) if not data is None: volume_plot = _create_time_and_volume_histogram(data).opts( responsive=True) candle_stick_plot = create_candle_stick(data).opts(responsive=True) pav_plot = _create_price_and_volume_histogram(data).opts( responsive=True) gridspec[0:2, 0:8] = volume_plot gridspec[2:10, 0:8] = candle_stick_plot gridspec[2:10, 8:10] = pav_plot return gridspec
def create_dashboard(): mgrDir_list = ['Manager', 'Director'] mgrDirWidget = pn.interact(mgrDir, ManagerDirector=mgrDir_list) assignmentsWidget = pn.interact( chooseAssignmentLevel, Quarter_Detail=['With_Quarters', 'Without_Quarters'], ManagerDirector=mgrDir_list) managerJobsWidget = pn.interact(displayManagerJobs, Manager=df['Manager'].unique(), ManagerDirector=mgrDir_list) gspec = pn.GridSpec(sizing_mode='stretch_both', max_height=800) gspec[0, :2] = pn.Row("# Novak Francella Manager/Partner Hours") gspec[1:4, 0] = mgrDirWidget gspec[1:6, 1] = pn.Column('') gspec[1:3, 2] = assignmentsWidget gspec[1:6, 3] = pn.Column('') gspec[1:6, 4] = managerJobsWidget return gspec
def plot_vsound(self): """ Compute the speed of sound by fitting phonon frequencies along selected directions by linear least-squares fit. """ if self.plot_vsound_btn.clicks == 0: return from abipy.dfpt.vsound import SoundVelocity sv = SoundVelocity.from_ddb(self.ddb.filepath, num_points=20, qpt_norm=0.1, ignore_neg_freqs=True, asr=self.asr, chneut=self.chneut, dipdip=self.dipdip, verbose=self.verbose, mpi_procs=self.mpi_procs) # Insert results in grid. gspec = pn.GridSpec(sizing_mode='scale_width') gspec[0, :1] = sv.get_dataframe() gspec[1, :1] = sv.plot(**self.fig_kwargs) return gspec
def plot_eps0w(self): """Compute eps0(omega) from DDB and plot the results.""" if self.plot_eps0w_btn.clicks == 0: return gen, inp = self.ddb.anaget_dielectric_tensor_generator( asr=self.asr, chneut=self.chneut, dipdip=self.dipdip, mpi_procs=self.mpi_procs, verbose=self.verbose, return_input=True) ws = self.w_range.value w_max = ws[1] if w_max == 1.0: w_max = None # Will compute w_max in plot routine from ph freqs. def p(component, reim): return gen.plot(w_min=ws[0], w_max=w_max, gamma_ev=self.gamma_ev, num=500, component=component, reim=reim, units=self.units, **self.fig_kwargs) # Build grid gspec = pn.GridSpec(sizing_mode='scale_width') gspec[0, 0] = p("diag", "re") gspec[0, 1] = p("diag", "im") gspec[1, 0] = p("offdiag", "re") gspec[1, 1] = p("offdiag", "im") gspec[2, :] = gen.get_oscillator_dataframe(reim="all", tol=1e-6) # Add HTML pane with input. gspec[3, 0] = pn.pane.HTML(inp._repr_html_()) return gspec
def panel(self): appbar = pn.Row( pn.pane.HTML( '''<div>Videogames sales dashboard</div>''', style={ "font-size": "4rem", "text-align": "left", "height": "10vh", "line-height": "10vh", "color": "#fcedd8", "background": "#d52e3f", "font-family": "Niconne, cursive", "font-weight": "200", "text-shadow": "2px 2px 0px #eb452b, 4px 4px 0px #efa032, 6px 6px 0px #46b59b, 8px 8px 0px #017e7f, 10px 10px 0px #052939, 12px 12px 0px #c11a2b, 14px 14px 0px #c11a2b, 16px 16px 0px #c11a2b, 18px 18px 0px #c11a2b" }, width=1000), pn.layout.HSpacer(height=0), pn.pane.PNG( "./scripts/cont.png", width=200, align="center", sizing_mode="fixed", margin=(10, 50, 10, 5), ), sizing_mode="stretch_width", css_classes=["app-bar"], ) gspec = pn.GridSpec(sizing_mode='stretch_both', background="#f2f2f2") gspec[0, :3] = pn.Column(appbar, pn.layout.HSpacer(height=10)) gspec[1, 0] = pn.Column(pn.Param(self.param, parameters=["piattaforma", "valore"], widgets={ "piattaforma": { "type": pn.widgets.Select, "inline": True, "align": "end", "color": "#fcba03" } }), css_classes=['app-container']) gspec[1, 1] = pn.Row( pn.layout.VSpacer(width=10), pn.Column(self.plot_1, css_classes=["app-container"])) gspec[1, 2] = pn.Row( pn.layout.VSpacer(width=10), pn.Column(self.plot_2, css_classes=["app-container"], sizing_mode="stretch_width")) gspec[2, 0] = pn.Row(pn.layout.VSpacer(width=10), self.Html_ret) gspec[2, 1] = pn.Row(self.Html_ret_2, width=100) return gspec
hvplot_plot = dataframe.hvplot(x="x", y="y") hvplot_pane = pn.pane.HoloViews(hvplot_plot, name="Holoviews Plot") altair_plot = ( alt.Chart(dataframe).mark_line().encode(x="x", y="y").properties(width="container", height=400) ) altair_pane = pn.pane.Vega(altair_plot, name="Altair Plot") plotly_plot = px.line(dataframe, x="x", y="y") plotly_pane = pn.pane.Plotly(plotly_plot, name="Plotly Plot") fig = figure() fig.scatter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 2, 1, 0, -1, -2, -3]) gspec = pn.GridSpec(sizing_mode="stretch_both", max_height=800, name="GridSpec") gspec[0, :3] = pn.Spacer(background="#FF0000") gspec[1:3, 0] = pn.Spacer(background="#0000FF") gspec[1:3, 1:3] = fig gspec[3:5, 0] = hv.Curve([1, 2, 3]) gspec[ 3:5, 1 ] = "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png" gspec[4:5, 2] = pn.Column( pn.widgets.FloatSlider(), pn.widgets.ColorPicker(), pn.widgets.Toggle(name="Toggle Me!") ) if st.checkbox("Only hv_plot?"): tabs = pn.Tabs(hvplot_pane)