当前位置: 首页>>代码示例>>Python>>正文


Python layouts.gridplot方法代码示例

本文整理汇总了Python中bokeh.layouts.gridplot方法的典型用法代码示例。如果您正苦于以下问题:Python layouts.gridplot方法的具体用法?Python layouts.gridplot怎么用?Python layouts.gridplot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.layouts的用法示例。


在下文中一共展示了layouts.gridplot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def plot(self, ncols=2):
        """
        :param ncols: Number of grid columns
        :return: a bokeh figure image
        """
        grid = gridplot(self.plots, ncols=ncols)
        return grid 
开发者ID:GiulioRossetti,项目名称:ndlib,代码行数:9,代码来源:MultiPlot.py

示例2: add_plot

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def add_plot(stockStat, conf):
    p_list = []
    logging.info("############################", type(conf["dic"]))
    # 循环 多个line 信息。
    for key, val in enumerate(conf["dic"]):
        logging.info(key)
        logging.info(val)

        p1 = figure(width=1000, height=150, x_axis_type="datetime")
        # add renderers
        stockStat["date"] = pd.to_datetime(stockStat.index.values)
        # ["volume","volume_delta"]
        # 设置20个颜色循环,显示0 2 4 6 号序列。
        p1.line(stockStat["date"], stockStat[val], color=Category20[20][key * 2])

        # Set date format for x axis 格式化。
        p1.xaxis.formatter = DatetimeTickFormatter(
            hours=["%Y-%m-%d"], days=["%Y-%m-%d"],
            months=["%Y-%m-%d"], years=["%Y-%m-%d"])
        # p1.xaxis.major_label_orientation = radians(30) #可以旋转一个角度。

        p_list.append([p1])

    gp = gridplot(p_list)
    script, div = components(gp)
    return {
        "script": script,
        "div": div,
        "title": conf["title"],
        "desc": conf["desc"]
    } 
开发者ID:pythonstock,项目名称:stock,代码行数:33,代码来源:dataIndicatorsHandler.py

示例3: _get_nodata_panel

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def _get_nodata_panel(self):
        chart_grid = gridplot([], toolbar_location=self.p.scheme.toolbar_location, toolbar_options={'logo': None})
        return Panel(child=chart_grid, title="No Data") 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:5,代码来源:bokeh.py

示例4: get_analyzer_panel

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
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') 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:16,代码来源:bokeh.py

示例5: show_layout

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
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) 
开发者ID:arviz-devs,项目名称:arviz,代码行数:11,代码来源:__init__.py

示例6: exec_file

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def exec_file(self):
        print("running {0}".format(self.filename))

        thumbfile = op.join("example_thumbs", self.thumbfilename)
        cx, cy = self.thumbloc
        pngfile = op.join(self.target_dir, self.pngfilename)
        plt.close("all")
        if self.backend == "matplotlib":
            my_globals = {"pl": plt, "plt": plt}
            with open(self.filename, "r") as fp:
                code_text = fp.read()
                code_text = re.sub(r"(plt\.show\S+)", "", code_text)
                exec(compile(code_text, self.filename, "exec"), my_globals)

            fig = plt.gcf()
            fig.canvas.draw()
            fig.savefig(pngfile, dpi=75)

        elif self.backend == "bokeh":
            pngfile = thumbfile
            with open(self.filename, "r") as fp:
                code_text = fp.read()
                code_text += BOKEH_EXPORT_CODE.format(pngfilename=thumbfile)
                with rc_context(rc={"plot.bokeh.show": False}):
                    exec(
                        code_text,
                        {"export_png": export_png, "ndarray": ndarray, "gridplot": gridplot},
                    )

        create_thumbnail(pngfile, thumbfile, cx=cx, cy=cy) 
开发者ID:arviz-devs,项目名称:arviz,代码行数:32,代码来源:gallery_generator.py

示例7: modify_document

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def modify_document(self, doc):
        doc.clear()
        self.build_plot()
        layout = gridplot(self.plots, ncols=2)

        doc.add_root(layout)
        self._pcb = doc.add_periodic_callback(self.update_data, 10000)
        return doc 
开发者ID:ChristianTremblay,项目名称:BAC0,代码行数:10,代码来源:BokehRenderer.py

示例8: initialize_plot

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def initialize_plot(self, ranges=None, plots=[]):
        ranges = self.compute_ranges(self.layout, self.keys[-1], None)
        passed_plots = list(plots)
        plots = [[None for c in range(self.cols)] for r in range(self.rows)]
        for i, coord in enumerate(self.layout.keys(full_grid=True)):
            r = i % self.rows
            c = i // self.rows
            subplot = self.subplots.get(wrap_tuple(coord), None)
            if subplot is not None:
                plot = subplot.initialize_plot(ranges=ranges, plots=passed_plots)
                plots[r][c] = plot
                passed_plots.append(plot)
            else:
                passed_plots.append(None)

        plot = gridplot(plots[::-1], merge_tools=self.merge_tools,
                        sizing_mode=self.sizing_mode,
                        toolbar_location=self.toolbar)
        plot = self._make_axes(plot)

        title = self._get_title_div(self.keys[-1])
        if title:
            plot = Column(title, plot)
            self.handles['title'] = title

        self.handles['plot'] = plot
        self.handles['plots'] = plots

        self._update_callbacks(plot)
        if self.shared_datasource:
            self.sync_sources()

        if self.top_level:
            self.init_links()

        self.drawn = True

        return self.handles['plot'] 
开发者ID:holoviz,项目名称:holoviews,代码行数:40,代码来源:plot.py

示例9: _make_axes

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def _make_axes(self, plot):
        width, height = self.renderer.get_size(plot)
        x_axis, y_axis = None, None
        keys = self.layout.keys(full_grid=True)
        if self.xaxis:
            flip = self.shared_xaxis
            rotation = self.xrotation
            lsize = self._fontsize('xlabel').get('fontsize')
            tsize = self._fontsize('xticks', common=False).get('fontsize')
            xfactors = list(unique_iterator([wrap_tuple(k)[0] for k in keys]))
            x_axis = make_axis('x', width, xfactors, self.layout.kdims[0],
                               flip=flip, rotation=rotation, label_size=lsize,
                               tick_size=tsize)
        if self.yaxis and self.layout.ndims > 1:
            flip = self.shared_yaxis
            rotation = self.yrotation
            lsize = self._fontsize('ylabel').get('fontsize')
            tsize = self._fontsize('yticks', common=False).get('fontsize')
            yfactors = list(unique_iterator([k[1] for k in keys]))
            y_axis = make_axis('y', height, yfactors, self.layout.kdims[1],
                               flip=flip, rotation=rotation, label_size=lsize,
                               tick_size=tsize)
        if x_axis and y_axis:
            plot = filter_toolboxes(plot)
            r1, r2 = ([y_axis, plot], [None, x_axis])
            if self.shared_xaxis:
                r1, r2 = r2, r1
            if self.shared_yaxis:
                x_axis.margin = (0, 0, 0, 50)
                r1, r2 = r1[::-1], r2[::-1]
            plot = gridplot([r1, r2])
        elif y_axis:
            models = [y_axis, plot]
            if self.shared_yaxis: models = models[::-1]
            plot = Row(*models)
        elif x_axis:
            models = [plot, x_axis]
            if self.shared_xaxis: models = models[::-1]
            plot = Column(*models)
        return plot 
开发者ID:holoviz,项目名称:holoviews,代码行数:42,代码来源:plot.py

示例10: health

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def health():

    '''
    # Health
    '''

    '''
    $contents
    '''

    '''
    ## Load Data
    
    Open a connection to the database and load the data we require.
    '''

    s = session('-v2')
    health = std_health_statistics(s)

    '''
    ## Health and Fitness
    '''

    output_file(filename='/dev/null')

    fitness, fatigue = like(N.FITNESS_ANY, health.columns), like(N.FATIGUE_ANY, health.columns)
    colours = ['black'] * len(fitness) + ['red'] * len(fatigue)
    alphas = [1.0] * len(fitness) + [0.5] * len(fatigue)
    ff = multi_line_plot(900, 300, N.TIME, fitness + fatigue, health, colours, alphas=alphas)
    xrange = ff.x_range if ff else None
    add_multi_line_at_index(ff, N.TIME, fitness + fatigue, health, colours, alphas=alphas, index=-1)
    atd = std_distance_time_plot(900, 200, health, x_range=xrange)
    shr = multi_plot(900, 200, N.TIME, [N.DAILY_STEPS, N.REST_HR_BPM], health, ['grey', 'red'], alphas=[1, 0.5],
                     x_range=xrange, rescale=True, plotters=[bar_plotter(dt.timedelta(hours=20)), dot_plotter()])
    add_curve(shr, N.TIME, N.REST_HR_BPM, health, color='red', y_range_name=N.REST_HR_BPM)
    show(gridplot([[ff], [atd], [shr]])) 
开发者ID:andrewcooke,项目名称:choochoo,代码行数:38,代码来源:health.py

示例11: plot_cross_variograms

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def plot_cross_variograms(trace, lags, df, n_exp=2, n_gaus=2, iter_plot=200, experimental=None):
    n_equations = trace['weights'].shape[1]
    n_iter = trace['weights'].shape[0]
    lags_tiled = np.tile(lags, (iter_plot, 1))
    b_var = []
    for i in range(0, df.shape[1]):  # n_equations, (n_exp+n_gaus)):
        # Init tensor
        b = np.zeros((len(lags), n_iter, 0))
        for i_exp in range(0, n_exp):
            # print(i_exp, "exp")
            b = np.dstack((b, trace['weights'][:, i_exp + i * (n_exp + n_gaus)] *
                           exp_vario(lags, trace['sill'][:, i_exp], trace['range'][:, i_exp])))
        for i_gaus in range(n_exp, n_gaus + n_exp):
            # print(i_gaus)
            b = np.dstack((b, trace['weights'][:, i_gaus + i * (n_exp + n_gaus)] *
                           gaus_vario(lags, trace['sill'][:, i_gaus], trace['range'][:, i_gaus])))
        # Sum the contributins of each function
        b_all = b.sum(axis=2)
        # Append each variable
        b_var.append(b_all[:, -iter_plot:].T)

    p_all = []
    for e, el in enumerate(df.columns):
        p = bp.figure(x_axis_type="log")
        p.multi_line(list(lags_tiled), list(b_var[e]), color='olive', alpha=0.08)
        if experimental is not None:
            p.scatter(experimental['lags'], y=experimental[el], color='navy', size=2)
        p.title.text = el
        p.xaxis.axis_label = "lags"
        p.yaxis.axis_label = "Semivariance"

        p_all = np.append(p_all, p)

    grid = bl.gridplot(list(p_all), ncols=5, plot_width=200, plot_height=150)

    show(grid) 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:38,代码来源:coKriging.py

示例12: plot_cross_covariance

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def plot_cross_covariance(trace, lags, df, n_exp=2, n_gaus=2, nuggets=None, iter_plot=200):
    n_equations = trace['weights'].shape[1]
    n_iter = trace['weights'].shape[0]
    lags_tiled = np.tile(lags, (iter_plot, 1))
    b_var = []
    for i in range(0, df.shape[1]):  # n_equations, (n_exp+n_gaus)):
        # Init tensor
        b = np.zeros((len(lags), n_iter, 0))
        for i_exp in range(0, n_exp):
            # print(i_exp, "exp")
            b = np.dstack((b, trace['weights'][:, i_exp + i * (n_exp + n_gaus)] *
                           exp_vario(lags, trace['sill'][:, i_exp], trace['range'][:, i_exp])))
        for i_gaus in range(n_exp, n_gaus + n_exp):
            # print(i_gaus)
            b = np.dstack((b, trace['weights'][:, i_gaus + i * (n_exp + n_gaus)] *
                           gaus_vario(lags, trace['sill'][:, i_gaus], trace['range'][:, i_gaus])))
        # Sum the contributins of each function
        if nuggets is not None:
            b_all = 1 - (b.sum(axis=2) + nuggets[i])
        else:
            b_all = 1 - (b.sum(axis=2))
        # Append each variable
        b_var.append(b_all[:, -iter_plot:].T)

    p_all = []
    for e, el in enumerate(df.columns):
        p = bp.figure(x_axis_type="log")
        p.multi_line(list(lags_tiled), list(b_var[e]), color='olive', alpha=0.08)

        p.title.text = el
        p.xaxis.axis_label = "lags"
        p.yaxis.axis_label = "Semivariance"

        p_all = np.append(p_all, p)

    grid = bl.gridplot(list(p_all), ncols=5, plot_width=250, plot_height=150)

    show(grid) 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:40,代码来源:coKriging.py

示例13: comparison_plot

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def comparison_plot(
    results,
    color_dict=None,
    height=None,
    width=500,
    axis_for_every_parameter=False,
    x_padding=0.1,
    num_bins=50,
):
    """Make a comparison plot from a dictionary containing optimization results.

    Args:
        results (list): List of estimagic optimization results where the info
            can have been extended with 'model' and 'model_name'
        color_dict (dict):
            mapping from the model class names to colors.
        height (int):
            height of the plot.
        width (int):
            width of the plot (in pixels).
        axis_for_every_parameter (bool):
            if False the x axis is only shown once for every group of parameters.
        x_padding (float): the x_range is extended on each side by x_padding
            times the range of the data
        num_bins (int): number of bins

    Returns:
        source_dfs, grid
    """
    source_dfs, plot_info = comparison_plot_inputs(
        results=results,
        x_padding=x_padding,
        num_bins=num_bins,
        color_dict=color_dict,
        fig_height=height,
    )

    source_dict, figure_dict, glyph_dict = _create_comparison_plot_components(
        source_dfs=source_dfs,
        plot_info=plot_info,
        axis_for_every_parameter=axis_for_every_parameter,
        width=width,
    )

    model_classes = sorted({res.info["model_class"] for res in results})

    plots_with_callbacks = _add_callbacks(
        source_dict=source_dict,
        figure_dict=figure_dict,
        glyph_dict=glyph_dict,
        model_classes=model_classes,
    )

    grid = gridplot(plots_with_callbacks, toolbar_location="right", ncols=1)
    show(grid)
    return source_dfs, grid 
开发者ID:OpenSourceEconomics,项目名称:estimagic,代码行数:58,代码来源:comparison_plot.py

示例14: generate_model_tabs

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def generate_model_tabs(self, fp: FigurePage, tradingdomain=None) -> List[Panel]:
        observers = [x for x in fp.figure_envs if isinstance(x.master, bt.Observer)]
        datas = [x for x in fp.figure_envs if isinstance(x.master, bt.DataBase)]
        inds = [x for x in fp.figure_envs if isinstance(x.master, bt.Indicator)]

        # now assign figures to tabs
        # 1. assign default tabs if no manual tab is assigned
        for figure in [x for x in datas if x.plottab is None]:
            figure.plottab = 'Plots' if self.is_tabs_single else 'Datas'

        for figure in [x for x in inds if x.plottab is None]:
            figure.plottab = 'Plots' if self.is_tabs_single else 'Indicators'

        for figure in [x for x in observers if x.plottab is None]:
            figure.plottab = 'Plots' if self.is_tabs_single else 'Observers'

        # 2. group panels by desired tabs
        # groupby expects the groups to be sorted or else will produce duplicated groups
        sorted_figs = list(itertools.chain(datas, inds, observers))

        # 3. filter tradingdomains
        if tradingdomain is not None:
            filtered = []
            for f in sorted_figs:
                lgs = f.get_tradingdomains()
                for lg in lgs:
                    if lg is True or lg == tradingdomain:
                        filtered.append(f)
            sorted_figs = filtered

        sorted_figs.sort(key=lambda x: x.plottab)
        tabgroups = itertools.groupby(sorted_figs, lambda x: x.plottab)

        panels = []

        def build_panel(objects, panel_title):
            if len(objects) == 0:
                return

            Bokeh._sort_plotobjects(objects)

            g = gridplot([[x.figure] for x in objects],
                         toolbar_options={'logo': None},
                         toolbar_location=self.p.scheme.toolbar_location,
                         sizing_mode=self.p.scheme.plot_sizing_mode,
                         )
            panels.append(Panel(title=panel_title, child=g))

        for tabname, figures in tabgroups:
            build_panel(list(figures), tabname)

        return panels
    # endregion 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:55,代码来源:bokeh.py

示例15: create_layout

# 需要导入模块: from bokeh import layouts [as 别名]
# 或者: from bokeh.layouts import gridplot [as 别名]
def create_layout(ax, force_layout=False):
    """Transform bokeh array of figures to layout."""
    ax = np.atleast_2d(ax)
    subplot_order = rcParams["plot.bokeh.layout.order"]
    if force_layout:
        from bokeh.layouts import gridplot as layout

        ax = ax.tolist()
        layout_args = {
            "sizing_mode": rcParams["plot.bokeh.layout.sizing_mode"],
            "toolbar_location": rcParams["plot.bokeh.layout.toolbar_location"],
        }
    elif any(item in subplot_order for item in ("row", "column")):
        # check number of rows
        match = re.match(r"(\d*)(row|column)", subplot_order)
        n = int(match.group(1)) if match.group(1) is not None else 1
        subplot_order = match.group(2)
        # set up 1D list of axes
        ax = [item for item in ax.ravel().tolist() if item is not None]
        layout_args = {"sizing_mode": rcParams["plot.bokeh.layout.sizing_mode"]}
        if subplot_order == "row" and n == 1:
            from bokeh.layouts import row as layout
        elif subplot_order == "column" and n == 1:
            from bokeh.layouts import column as layout
        else:
            from bokeh.layouts import layout

        if n != 1:
            ax = np.array(ax + [None for _ in range(int(np.ceil(len(ax) / n)) - len(ax))])
            if subplot_order == "row":
                ax = ax.reshape(n, -1)
            else:
                ax = ax.reshape(-1, n)
            ax = ax.tolist()
    else:
        if subplot_order in ("square", "square_trimmed"):
            ax = [item for item in ax.ravel().tolist() if item is not None]
            n = int(np.ceil(len(ax) ** 0.5))
            ax = ax + [None for _ in range(n ** 2 - len(ax))]
            ax = np.array(ax).reshape(n, n)
        ax = ax.tolist()
        if (subplot_order == "square_trimmed") and any(
            all(item is None for item in row) for row in ax
        ):
            from bokeh.layouts import layout

            ax = [row for row in ax if not all(item is None for item in row)]
            layout_args = {"sizing_mode": rcParams["plot.bokeh.layout.sizing_mode"]}
        else:
            from bokeh.layouts import gridplot as layout

            layout_args = {
                "sizing_mode": rcParams["plot.bokeh.layout.sizing_mode"],
                "toolbar_location": rcParams["plot.bokeh.layout.toolbar_location"],
            }
    # ignore "fixed" sizing_mode without explicit width and height
    if layout_args.get("sizing_mode", "") == "fixed":
        layout_args.pop("sizing_mode")
    return layout(ax, **layout_args) 
开发者ID:arviz-devs,项目名称:arviz,代码行数:61,代码来源:__init__.py


注:本文中的bokeh.layouts.gridplot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。