Python bokeh.layouts.column() Examples

The following are 30 code examples of bokeh.layouts.column(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module bokeh.layouts , or try the search function .
Example #1
Source File: temperature.py    From bigquery-bokeh-dashboard with Apache License 2.0 7 votes vote down vote up
def make_plot(self, dataframe):
        self.source = ColumnDataSource(data=dataframe)
        self.plot = figure(
            x_axis_type="datetime", plot_width=600, plot_height=300,
            tools='', toolbar_location=None)
        self.plot.quad(
            top='max_temp', bottom='min_temp', left='left', right='right',
            color=Blues4[2], source=self.source, legend='Magnitude')
        line = self.plot.line(
            x='date', y='avg_temp', line_width=3, color=Blues4[1],
            source=self.source, legend='Average')
        hover_tool = HoverTool(tooltips=[
            ('Value', '$y'),
            ('Date', '@date_readable'),
        ], renderers=[line])
        self.plot.tools.append(hover_tool)

        self.plot.xaxis.axis_label = None
        self.plot.yaxis.axis_label = None
        self.plot.axis.axis_label_text_font_style = 'bold'
        self.plot.x_range = DataRange1d(range_padding=0.0)
        self.plot.grid.grid_line_alpha = 0.3

        self.title = Paragraph(text=TITLE)
        return column(self.title, self.plot) 
Example #2
Source File: bokeh_event_viewer.py    From ctapipe with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create(self):
        for _ in range(self.num_cameras):
            cam = BokehEventViewerCamera(self)
            cam.enable_pixel_picker(self.num_waveforms)
            cam.create_view_widget()
            cam.update_view_widget()
            cam.add_colorbar()

            self.cameras.append(cam)
            self.camera_layouts.append(cam.layout)

        for iwav in range(self.num_waveforms):
            wav = BokehEventViewerWaveform(self)
            active_color = self.cameras[0].active_colors[iwav]
            wav.fig.select(name="line")[0].glyph.line_color = active_color
            wav.enable_time_picker()
            wav.create_view_widget()
            wav.update_view_widget()

            self.waveforms.append(wav)
            self.waveform_layouts.append(wav.layout)

        self.layout = layout(
            [[column(self.camera_layouts), column(self.waveform_layouts)],]
        ) 
Example #3
Source File: optbrowser.py    From backtrader_plotting with GNU General Public License v3.0 6 votes vote down vote up
def _build_optresult_selector(self, optresults) -> Tuple[DataTable, ColumnDataSource]:
        # 1. build a dict with all params and all user columns
        data_dict = defaultdict(list)
        for optres in optresults:
            for param_name, _ in optres[0].params._getitems():
                param_val = optres[0].params._get(param_name)
                data_dict[param_name].append(param_val)

            for usercol_label, usercol_fnc in self._usercolumns.items():
                data_dict[usercol_label].append(usercol_fnc(optres))

        # 2. build a pandas DataFrame
        df = DataFrame(data_dict)

        # 3. now sort and limit result
        if self._sortcolumn is not None:
            df = df.sort_values(by=[self._sortcolumn], ascending=self._sortasc)

        if self._num_result_limit is not None:
            df = df.head(self._num_result_limit)

        # 4. build column info for Bokeh table
        tab_columns = []
        for colname in data_dict.keys():
            formatter = NumberFormatter(format='0.000')

            if len(data_dict[colname]) > 0 and isinstance(data_dict[colname][0], int):
                formatter = StringFormatter()

            tab_columns.append(TableColumn(field=colname, title=f'{colname}', sortable=False, formatter=formatter))

        # TODO: currently table size is hardcoded
        cds = ColumnDataSource(df)
        selector = DataTable(source=cds, columns=tab_columns, width=1600, height=150)
        return selector, cds 
Example #4
Source File: tornado_bokeh_embed.py    From stock with Apache License 2.0 6 votes vote down vote up
def modify_doc(doc):
    df = sea_surface_temperature.copy()
    source = ColumnDataSource(data=df)

    plot = figure(x_axis_type='datetime', y_range=(0, 25), y_axis_label='Temperature (Celsius)',
                  title="Sea Surface Temperature at 43.18, -70.43")
    plot.line('time', 'temperature', source=source)

    def callback(attr, old, new):
        if new == 0:
            data = df
        else:
            data = df.rolling('{0}D'.format(new)).mean()
        source.data = ColumnDataSource(data=data).data

    slider = Slider(start=0, end=30, value=0, step=1, title="Smoothing by N Days")
    slider.on_change('value', callback)

    doc.add_root(column(slider, plot))

    # doc.theme = Theme(filename="theme.yaml") 
Example #5
Source File: precipitation.py    From bigquery-bokeh-dashboard with Apache License 2.0 6 votes vote down vote up
def make_plot(self, dataframe):
        self.source = ColumnDataSource(data=dataframe)
        self.plot = figure(
            x_axis_type="datetime", plot_width=400, plot_height=300,
            tools='', toolbar_location=None)

        vbar = self.plot.vbar(
            x='date', top='prcp', width=1, color='#fdae61', source=self.source)
        hover_tool = HoverTool(tooltips=[
            ('Value', '$y'),
            ('Date', '@date_readable'),
        ], renderers=[vbar])
        self.plot.tools.append(hover_tool)

        self.plot.xaxis.axis_label = None
        self.plot.yaxis.axis_label = None
        self.plot.axis.axis_label_text_font_style = 'bold'
        self.plot.x_range = DataRange1d(range_padding=0.0)
        self.plot.grid.grid_line_alpha = 0.3

        self.title = Paragraph(text=TITLE)
        return column(self.title, self.plot) 
Example #6
Source File: air.py    From bigquery-bokeh-dashboard with Apache License 2.0 6 votes vote down vote up
def make_plot(self, dataframe):
        self.source = ColumnDataSource(data=dataframe)
        palette = all_palettes['Set2'][6]
        hover_tool = HoverTool(tooltips=[
            ("Value", "$y"),
            ("Year", "@year"),
        ])
        self.plot = figure(
            plot_width=600, plot_height=300, tools=[hover_tool],
            toolbar_location=None)
        columns = {
            'pm10': 'PM10 Mass (µg/m³)',
            'pm25_frm': 'PM2.5 FRM (µg/m³)',
            'pm25_nonfrm': 'PM2.5 non FRM (µg/m³)',
            'lead': 'Lead (¹/₁₀₀ µg/m³)',
        }
        for i, (code, label) in enumerate(columns.items()):
            self.plot.line(
                x='year', y=code, source=self.source, line_width=3,
                line_alpha=0.6, line_color=palette[i], legend=label)

        self.title = Paragraph(text=TITLE)
        return column(self.title, self.plot)
# [END make_plot] 
Example #7
Source File: population.py    From bigquery-bokeh-dashboard with Apache License 2.0 6 votes vote down vote up
def make_plot(self, dataframe):
        self.source = ColumnDataSource(data=dataframe)
        self.title = Paragraph(text=TITLE)
        self.data_table = DataTable(source=self.source, width=390, height=275, columns=[
            TableColumn(field="zipcode", title="Zipcodes", width=100),
            TableColumn(field="population", title="Population", width=100, formatter=NumberFormatter(format="0,0")),
            TableColumn(field="city", title="City")
        ])
        return column(self.title, self.data_table) 
Example #8
Source File: test_bokeh_server.py    From choochoo with GNU General Public License v2.0 6 votes vote down vote up
def modify_doc(doc):
    df = sea_surface_temperature.copy()
    source = ColumnDataSource(data=df)

    plot = figure(x_axis_type='datetime', y_range=(0, 25), y_axis_label='Temperature (Celsius)',
                  title="Sea Surface Temperature at 43.18, -70.43")
    plot.line('time', 'temperature', source=source)

    def callback(attr, old, new):
        if new == 0:
            data = df
        else:
            data = df.rolling('{0}D'.format(new)).mean()
        source.data = ColumnDataSource(data=data).data

    slider = Slider(start=0, end=30, value=0, step=1, title="Smoothing by N Days")
    slider.on_change('value', callback)

    doc.add_root(column(slider, plot))

    doc.theme = Theme(filename="theme.yaml") 
Example #9
Source File: parallel_coordinates.py    From CAVE with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _plot_budget(self, df):
        limits = OrderedDict([('cost', {'lower': df['cost'].min(),
                                        'upper': df['cost'].max()})])
        for hp in self.runscontainer.scenario.cs.get_hyperparameters():
            if isinstance(hp, NumericalHyperparameter):
                limits[hp.name] = {'lower': hp.lower, 'upper': hp.upper}
                if hp.log:
                    limits[hp.name]['log'] = True
            elif isinstance(hp, CategoricalHyperparameter):
                # We pass strings as numbers and overwrite the labels
                df[hp.name].replace({v: i for i, v in enumerate(hp.choices)}, inplace=True)
                limits[hp.name] = {'lower': 0, 'upper': len(hp.choices) - 1, 'choices': hp.choices}
            else:
                raise ValueError("Hyperparameter %s of type %s causes undefined behaviour." % (hp.name, type(hp)))
        p = parallel_plot(df=df, axes=limits, color=df[df.columns[0]], palette=Viridis256)
        div = Div(text="Select up and down column grid lines to define filters. Double click a filter to reset it.")
        plot = column(div, p)
        return plot 
Example #10
Source File: experiment_board.py    From coach with Apache License 2.0 6 votes vote down vote up
def create_files_signal(files, use_dir_name=False):
    global selected_file
    new_signal_files = []
    for idx, file_path in enumerate(files):
        signals_file = SignalsFile(str(file_path), plot=plot, use_dir_name=use_dir_name)
        signals_files[signals_file.filename] = signals_file
        new_signal_files.append(signals_file)

    filenames = [f.filename for f in new_signal_files]

    if files_selector.options[0] == "":
        files_selector.options = filenames
    else:
        files_selector.options = files_selector.options + filenames
    files_selector.value = filenames[0]
    selected_file = new_signal_files[0]

    # update x axis according to the file's default x-axis (which is the index, and thus the first column)
    idx = x_axis_options.index(new_signal_files[0].csv.columns[0])
    change_x_axis(idx)
    x_axis_selector.active = idx 
Example #11
Source File: controllers.py    From tethys with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def home_handler(doc):
    data = {'x': [0, 1, 2, 3, 4, 5], 'y': [0, 10, 20, 30, 40, 50]}
    source = ColumnDataSource(data=data)

    plot = figure(x_axis_type="linear", y_range=(0, 50), title="Test App Bokeh + Channels Plot", height=250)
    plot.line(x="x", y="y", source=source)

    def callback(attr: str, old: Any, new: Any) -> None:
        if new == 1:
            data['y'] = [0, 10, 20, 30, 40, 50]
        else:
            data['y'] = [i * new for i in [0, 10, 20, 30, 40, 50]]
        source.data = dict(ColumnDataSource(data=data).data)
        plot.y_range.end = max(data['y'])

    slider = Slider(start=1, end=5, value=1, step=1, title="Test App Bokeh + Channels Controller")
    slider.on_change("value", callback)

    doc.add_root(column(slider, plot)) 
Example #12
Source File: line.py    From choochoo with GNU General Public License v2.0 5 votes vote down vote up
def vtile(maps, n):
    return row([column(maps[i::n]) for i in range(n)]) 
Example #13
Source File: geoplot.py    From Pandas-Bokeh with MIT License 5 votes vote down vote up
def _get_figure(col):
    """Gets the bokeh.plotting.figure from a bokeh.layouts.column."""

    from bokeh.layouts import column
    from bokeh.plotting import figure

    for children in col.children:
        if isinstance(children, type(figure())):
            return children
        elif isinstance(children, type(column())):
            return _get_figure(children) 
Example #14
Source File: log.py    From DeepVideoCS with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def save(self, title='Training Results'):
        if len(self.figures) > 0:
            if os.path.isfile(self.plot_path):
                os.remove(self.plot_path)
            output_file(self.plot_path, title=title)
            plot = column(*self.figures)
            save(plot)
            self.clear()
        self.results.to_csv(self.path, index=False, index_label=False) 
Example #15
Source File: log.py    From DeepVideoCS with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def show(self):
        if len(self.figures) > 0:
            plot = column(*self.figures)
            show(plot) 
Example #16
Source File: line.py    From choochoo with GNU General Public License v2.0 5 votes vote down vote up
def htile(maps, n):
    return column([row(maps[i:i + n]) for i in range(0, len(maps), n)]) 
Example #17
Source File: client_demo.py    From pairstrade-fyp-2019 with MIT License 5 votes vote down vote up
def build_widgets_wb(stock_list, metrics):
    # CODE SECTION: setup buttons, widgetbox name = controls_wb
    WIDGET_WIDTH = 250

    # ========== Select Stocks ============= #
    select_stk_1 = Select(width = WIDGET_WIDTH, title='Select Stock 1:', value = backtest_params["stk_0"], options=stock_list)
    select_stk_2 = Select(width = WIDGET_WIDTH, title='Select Stock 2:', value = backtest_params["stk_1"], options=stock_list)

    # ========== Strategy Type ============= #
    strategy_list = ['kalman', 'distance', 'cointegration', 'reinforcement learning']
    select_strategy = Select(width = WIDGET_WIDTH, title='Select Strategy:', value = backtest_params["strategy_type"], options=strategy_list)

    # ========== set start/end date ============= #
    # date time variables
    MAX_START = datetime.strptime(backtest_params["max_start"], "%Y-%m-%d").date()
    MAX_END = datetime.strptime(backtest_params["max_end"], "%Y-%m-%d").date()
    DEFAULT_START = datetime.strptime(backtest_params["backtest_start"], "%Y-%m-%d").date()
    DEFAULT_END = datetime.strptime(backtest_params["backtest_end"], "%Y-%m-%d").date()
    STEP = 1

    backtest_dates = DateRangeSlider(width = WIDGET_WIDTH, 
                                     start=MAX_START, end=MAX_END, 
                                     value=(DEFAULT_START, DEFAULT_END), 
                                     step=STEP, title="Backtest Date Range:")

    start_bt = Button(label="Backtest", button_type="success", width = WIDGET_WIDTH)

    # controls = column(select_stk_1, select_stk_2, select_strategy, backtest_dates, start_bt)
    controls_wb = widgetbox(select_stk_1, select_stk_2, select_strategy, backtest_dates, start_bt, width=300)

    # CODE SECTION: setup table, widgetbox name = metrics_wb
    master_wb = None
    if metrics is not None:
        metric_source = ColumnDataSource(metrics)
        metric_columns = [
            TableColumn(field="Metrics", title="Metrics"),
            TableColumn(field="Value", title="Performance"),
        ]

        metric_table = DataTable(source=metric_source, columns=metric_columns, width=300)
        master_wb = row(controls_wb, widgetbox(metric_table))
        
    else:
        logging.info("creating controls without table")
        master_wb = row(controls_wb)
    return master_wb, select_stk_1, select_stk_2, select_strategy, backtest_dates, start_bt 
Example #18
Source File: layout.py    From pairstrade-fyp-2019 with MIT License 5 votes vote down vote up
def build_widgets_wb(stock_list):
    # CODE SECTION: setup widgets, widgetbox name = controls_wb
    WIDGET_WIDTH = 250

    # ========== Select Stocks ============= #
    select_stk_1 = Select(width = WIDGET_WIDTH, title='Select Stock 1:', value = stock_list[0], options=stock_list)
    select_stk_2 = Select(width = WIDGET_WIDTH, title='Select Stock 2:', value = stock_list[0], options=stock_list)

    # ========== Strategy Type ============= #
    strategy_list = ['kalman', 'distance', 'cointegration']
    select_strategy = Select(width = WIDGET_WIDTH, title='Select Strategy:', value = strategy_list[0], options=strategy_list)

    # ========== set start/end date ============= #
    # date time variables
    MAX_START = date(2014, 1, 1)
    MAX_END = date(2018, 12, 30)
    DEFAULT_START = date(2016, 5, 1)
    DEFAULT_END = date(2016, 12, 31)
    STEP = 1

    backtest_dates = DateRangeSlider(width = WIDGET_WIDTH, 
                                     start=MAX_START, end=MAX_END, 
                                     value=(DEFAULT_START, DEFAULT_END), 
                                     step=STEP, title="Backtest Date Range:")

    start_bt = Button(label="Backtest", button_type="success", width = WIDGET_WIDTH)

    # controls = column(select_stk_1, select_stk_2, select_strategy, backtest_dates, start_bt)
    controls_wb = widgetbox(select_stk_1, select_stk_2, select_strategy, backtest_dates, start_bt, width=600)
    return controls_wb 
Example #19
Source File: __init__.py    From arviz with Apache License 2.0 5 votes vote down vote up
def show_layout(ax, show=True, force_layout=False):
    """Create a layout and call bokeh show."""
    if show is None:
        show = rcParams["plot.bokeh.show"]
    if show:
        import bokeh.plotting as bkp

        layout = create_layout(ax, force_layout=force_layout)
        bkp.show(layout) 
Example #20
Source File: quality_analysis.py    From drizzlepac with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def get_pandas_data(pandas_filename):
    """Load the harvested data, stored in a CSV file, into local arrays.

    Parameters
    ==========
    pandas_filename: str
        Name of the CSV file created by the harvester.

    Returns
    =======
    phot_data: Pandas dataframe
        Dataframe which is a subset of the input Pandas dataframe written out as
        a CSV file.  The subset dataframe consists of only the requested columns
        and rows where all of the requested columns did not contain NaNs.

    """
    
    # Instantiate a Pandas Dataframe Reader (lazy instantiation)
    # df_handle = PandasDFReader_CSV("svm_qa_dataframe.csv")
    df_handle = PandasDFReader(pandas_filename, log_level=logutil.logging.NOTSET)

    # In this particular case, the names of the desired columns do not
    # have to be further manipulated, for example, to add dataset specific
    # names.
    # 
    # Get the relevant column data, eliminating all rows which have NaNs
    # in any of the relevant columns.
    if pandas_filename.endswith('.h5'):
        fit_data = df_handle.get_columns_HDF5(HOVER_COLUMNS + RESULTS_COLUMNS)
        source_data = df_handle.get_columns_HDF5(HOVER_COLUMNS + SOURCE_COLUMNS)
    else:
        fit_data = df_handle.get_columns_CSV(HOVER_COLUMNS + RESULTS_COLUMNS)
        source_data = df_handle.get_columns_CSV(HOVER_COLUMNS + SOURCE_COLUMNS)

    return fit_data, source_data 
Example #21
Source File: liveclient.py    From backtrader_plotting with GNU General Public License v3.0 5 votes vote down vote up
def _get_config_panel(self):
        def on_change_checkbox(vals):
            for i, f in enumerate(self._bokeh.figurepages[0].figure_envs):
                if i > 1:
                    continue
                f.figure.visible = i in vals

        self._slider_aspectratio = Slider(value=self._scheme.plotaspectratio, start=0.1, end=10.0, step=0.1)

        button = Button(label="Save", button_type="success")
        button.on_click(self.on_button_save_config)

        r1 = row(children=[Div(text='Aspect Ratio', margin=(15, 10, 0, 10)), self._slider_aspectratio])

        return Panel(child=column(children=[r1, button]), title='Config') 
Example #22
Source File: liveclient.py    From backtrader_plotting with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, doc: Document, push_fnc, bokeh_fac: callable, push_data_fnc:callable, strategy: bt.Strategy, figurepage_idx: int = 0, lookback: int = 20):
        self._slider_aspectratio = None
        self._push_data_fnc = push_data_fnc
        self._push_fnc = push_fnc
        self._figurepage_idx = figurepage_idx
        self.last_data_index = -1
        self._lookback = lookback
        self._strategy = strategy
        self._current_group = None
        self.document = doc

        self._bokeh_fac = bokeh_fac
        self._bokeh = None

        bokeh = self._bokeh_fac()  # temporary bokeh object to get tradingdomains and scheme
        self._scheme = copy(bokeh.p.scheme)  # preserve original scheme as originally provided by the user

        tradingdomains = bokeh.list_tradingdomains(strategy)
        self._current_group = tradingdomains[0]
        self._select_tradingdomain = Select(value=self._current_group, options=tradingdomains)
        self._select_tradingdomain.on_change('value', self._on_select_group)

        btn_refresh_analyzers = Button(label='Refresh Analyzers', width=100)
        btn_refresh_analyzers.on_click(self._on_click_refresh_analyzers)

        td_label = Div(text="Trading Domain:", margin=(9, 5, 15, 5))
        controls = row(children=[td_label, self._select_tradingdomain, btn_refresh_analyzers])
        self.model = column(children=[controls, Tabs(tabs=[])], sizing_mode=self._scheme.plot_sizing_mode)

        # append meta tab
        meta = Div(text=metadata.get_metadata_div(strategy))
        self._panel_metadata = Panel(child=meta, title="Meta")

        self._refreshmodel() 
Example #23
Source File: bokeh.py    From backtrader_plotting with GNU General Public License v3.0 5 votes vote down vote up
def get_analyzer_panel(self, analyzers: List[bt.Analyzer]) -> Optional[Panel]:
        if len(analyzers) == 0:
            return None

        table_width = int(self.p.scheme.analyzer_tab_width / self.p.scheme.analyzer_tab_num_cols)

        acolumns = []
        for analyzer in analyzers:
            table_header, elements = self._tablegen.get_analyzers_tables(analyzer, table_width)

            acolumns.append(column([table_header] + elements))

        childs = gridplot(acolumns, ncols=self.p.scheme.analyzer_tab_num_cols, toolbar_options={'logo': None})
        return Panel(child=childs, title='Analyzers') 
Example #24
Source File: process_tree.py    From msticpy with MIT License 5 votes vote down vote up
def build(self, schema: ProcSchema = None, **kwargs) -> pd.DataFrame:
        """
        Build process trees from the process events.

        Parameters
        ----------
        procs : pd.DataFrame
            Process events (Windows 4688 or Linux Auditd)
        schema : ProcSchema, optional
            The column schema to use, by default None
            If None, then the schema is inferred
        show_progress : bool
            Shows the progress of the process (helpful for
            very large data sets)
        debug : bool
            If True produces extra debugging output,
            by default False

        Returns
        -------
        pd.DataFrame
            Process tree dataframe.

        Notes
        -----
        It is not necessary to call this before `plot`. The process
        tree is built automatically. This is only needed if you want
        to return the processed tree data as a DataFrame

        """
        return build_process_tree(
            procs=self._df,
            schema=schema,
            show_progress=kwargs.get("show_progress", False),
            debug=kwargs.get("debug", False),
        ) 
Example #25
Source File: timeline.py    From msticpy with MIT License 5 votes vote down vote up
def _create_data_grouping(data, source_columns, time_column, group_by, color):
    if not source_columns:
        data_columns = set(["NewProcessName", "EventID", "CommandLine"])
    else:
        data_columns = set(source_columns)
    tool_tip_columns = data_columns.copy()
    # If the time column not explicity specified in source_columns, add it
    data_columns.add(time_column)
    # create group frame so that we can color each group separately
    if group_by:
        group_count_df = (
            data[[group_by, time_column]]
            .groupby(group_by)
            .count()
            .reset_index()
            .rename(columns={time_column: "count"})
        )
        group_count_df["y_index"] = group_count_df.index

        # Shift the Viridis palatte so we lose the top, harder-to-see colors
        series_count = len(group_count_df)
        colors, palette_size = _get_color_palette(series_count)
        group_count_df["color"] = group_count_df.apply(
            lambda x: colors[x.y_index % palette_size], axis=1
        )
        # re-join with the original data
        data_columns.update([group_by, "y_index", "color"])
        clean_data = data.drop(columns=["y_index", "color"], errors="ignore")
        graph_df = clean_data.merge(group_count_df, on=group_by)[list(data_columns)]
    else:
        graph_df = data[list(data_columns)].copy()
        graph_df["color"] = color
        graph_df["y_index"] = 1
        series_count = 1
        group_count_df = None
    return graph_df, group_count_df, tool_tip_columns, series_count


# pylint: enable=too-many-arguments 
Example #26
Source File: bokeh_event_viewer.py    From ctapipe with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def create_view_widget(self):
        self.w_view = Select(title="View:", value="", options=[], width=5)
        self.w_view.on_change("value", self.on_view_widget_change)
        self.layout = column([self.w_view, self.layout]) 
Example #27
Source File: widgets.py    From parambokeh with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def PlotWidget(*args, **kw):
    return column(name=kw['name']) 
Example #28
Source File: compare_experiments.py    From convNet.pytorch with MIT License 5 votes vote down vote up
def main():
    args = parser.parse_args()
    title = 'comparison: ' + ','.join(args.experiments)
    x_axis_type = 'linear'
    y_axis_type = 'linear'
    width = 800
    height = 400
    line_width = 2
    tools = 'pan,box_zoom,wheel_zoom,box_select,hover,reset,save'
    results = {}
    for i, exp in enumerate(args.experiments):
        if args.legend is not None and len(args.legend) > i:
            name = args.legend[i]
        else:
            name = exp
        filename = exp + '/results.csv'
        results[name] = pd.read_csv(filename, index_col=None)
    figures = []
    for comp in args.compare:
        fig = figure(title=comp, tools=tools,
                     width=width, height=height,
                     x_axis_label=args.x_axis,
                     y_axis_label=comp,
                     x_axis_type=x_axis_type,
                     y_axis_type=y_axis_type)
        colors = cycle(args.colors)
        for i, (name, result) in enumerate(results.items()):
            fig.line(result[args.x_axis], result[comp],
                     line_width=line_width,
                     line_color=next(colors), legend=name)
        fig.legend.click_policy = "hide"
        figures.append(fig)

    plots = column(*figures)
    show(plots) 
Example #29
Source File: bokeh_qc_graphs.py    From rvt_model_services with MIT License 5 votes vote down vote up
def update_graphs(project_code, html_path):
    pd.set_option('display.width', 1800)
    html_path = op.join(html_path, "{0}.html".format(project_code))

    qc_path = op.dirname(op.abspath(__file__))
    commands_dir = op.dirname(qc_path)
    root_dir = op.dirname(commands_dir)
    log_dir = op.join(root_dir, "logs")

    csv_path = op.join(log_dir, project_code + ".csv")

    csv = pd.read_csv(csv_path, delimiter=";")
    csv.timeStamp = pd.to_datetime(csv.timeStamp)

    output_file(html_path, mode="inline")

    topics = {"q_": "QC",
              "l_": "LINKS",
              "g_": "GROUPS",
              "v_": "VIEWS",
              "d_": "2D",
              "s_": "STYLES",
              "e_": "ELEMENTS",
              "m_": "PROJECT_SQM",
              }

    graphs = graph(csv, project_code, topics)

    save(column(graphs), validate=False)
    print(colorful.bold_green(f" {html_path} updated successfully.")) 
Example #30
Source File: bokeh_qc_graphs.py    From rvt_model_services with MIT License 5 votes vote down vote up
def update_graphs(project_code, html_path):
    pd.set_option('display.width', 1800)
    html_path = op.join(html_path, "{0}.html".format(project_code))

    qc_path = op.dirname(op.abspath(__file__))
    commands_dir = op.dirname(qc_path)
    root_dir = op.dirname(commands_dir)
    log_dir = op.join(root_dir, "logs")

    csv_path = op.join(log_dir, project_code + ".csv")

    csv = pd.read_csv(csv_path, delimiter=";")
    csv.timeStamp = pd.to_datetime(csv.timeStamp)

    output_file(html_path, mode="inline")

    topics = {"q_": "QC",
              "l_": "LINKS",
              "g_": "GROUPS",
              "v_": "VIEWS",
              "d_": "2D",
              "s_": "STYLES",
              "e_": "ELEMENTS",
              "m_": "PROJECT_SQM",
              }

    graphs = graph(csv, project_code, topics)

    save(column(graphs), validate=False)
    print(colorful.bold_green(f" {html_path} updated successfully."))