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


Python models.ColumnDataSource方法代码示例

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


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

示例1: create

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
def create(clz):
        """One-time creation of app's objects.

        This function is called once, and is responsible for
        creating all objects (plots, datasources, etc)
        """
        self = clz()
        n_vals = 1000
        self.source = ColumnDataSource(
            data=dict(
                top=[],
                bottom=0,
                left=[],
                right=[],
                x= np.arange(n_vals),
                values= np.random.randn(n_vals)
                ))

        # Generate a figure container
        self.stock_plot = clz.create_stock(self.source)
        self.update_data()
        self.children.append(self.stock_plot) 
开发者ID:mvaz,项目名称:osqf2015,代码行数:24,代码来源:stock.py

示例2: make_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
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) 
开发者ID:GoogleCloudPlatform,项目名称:bigquery-bokeh-dashboard,代码行数:27,代码来源:temperature.py

示例3: make_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
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] 
开发者ID:GoogleCloudPlatform,项目名称:bigquery-bokeh-dashboard,代码行数:26,代码来源:air.py

示例4: make_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
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) 
开发者ID:GoogleCloudPlatform,项目名称:bigquery-bokeh-dashboard,代码行数:24,代码来源:precipitation.py

示例5: app

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
def app(doc):

    x,y = SineWave()
    source = ColumnDataSource(data=dict(x=x, y=y))

    import numpy as np # see TODO below about ranges
    plot = figure(plot_height=400, plot_width=400,
                  tools="crosshair,pan,reset,save,wheel_zoom",
                  x_range=[0, 4*np.pi], y_range=[-2.5, 2.5])
    plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)

    def update_sinewave(sw,**kw):
        x,y = sw()
        source.data = dict(x=x, y=y)
        # TODO couldn't figure out how to update ranges
        #plot.x_range.start,plot.x_range.end=pobj.x_range
        #plot.y_range.start,plot.y_range.end=pobj.y_range
    
    parambokeh.Widgets(SineWave, mode='server', doc=doc, callback=update_sinewave)
    doc.add_root(row(plot, width=800)) 
开发者ID:ioam,项目名称:parambokeh,代码行数:22,代码来源:bk_sliders.py

示例6: master_app

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
def master_app(doc, database_name_to_path, session_data):
    """Create the page with the master dashboard.

    Args:
        doc (bokeh.Document):
            document where the overview over the optimizations will be displayed
            by their current stage.
        database_name_to_path (dict):
            mapping from the short, unique names to the full paths to the databases.
        session_data (dict):
            infos to be passed between and within apps.
            Keys of the monitoring apps' entries are:
            - last_retrieved (int): last iteration currently in the ColumnDataSource
            - database_path

    """
    sec_to_elements = _create_section_to_elements(
        doc=doc, database_name_to_path=database_name_to_path
    )
    tabs = _setup_tabs(sec_to_elements=sec_to_elements)
    doc.add_root(tabs) 
开发者ID:OpenSourceEconomics,项目名称:estimagic,代码行数:23,代码来源:master_app.py

示例7: _map_dabase_name_to_bokeh_row_elements

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
def _map_dabase_name_to_bokeh_row_elements(doc, database_name_to_path):
    """Inner part of the sec_to_elements dictionary.

    For each entry that belongs to the section create a clickable link to that
    optimization's monitoring page.

    Args:
        doc (bokeh Document)
        database_name_to_path (dict): mapping from the short, unique names to the full
            paths to the databases.

    """
    name_to_row = {}
    for database_name in database_name_to_path:
        name_to_row[database_name] = [create_dashboard_link(database_name)]
    return ColumnDataSource(name_to_row) 
开发者ID:OpenSourceEconomics,项目名称:estimagic,代码行数:18,代码来源:master_app.py

示例8: _create_bokeh_data_sources

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
def _create_bokeh_data_sources(database, tables):
    """Load the first entry from the database to initialize the ColumnDataSources.

    Args:
        database (sqlalchemy.MetaData)
        tables (list): list of table names to load and convert to ColumnDataSources

    Returns:
        all_cds (list): list of ColumnDataSources

    """
    data_dict, _ = read_new_iterations(
        database=database,
        tables=tables,
        last_retrieved=0,
        limit=1,
        return_type="bokeh",
    )

    all_cds = []
    for tab, data in data_dict.items():
        cds = ColumnDataSource(data=data, name=f"{tab}_cds")
        all_cds.append(cds)
    return all_cds 
开发者ID:OpenSourceEconomics,项目名称:estimagic,代码行数:26,代码来源:monitoring_app.py

示例9: run

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
def run(self):
        print("In thread.run")
        self.p = figure(plot_height=500, tools=TOOLS, y_axis_location='left', title=self.title)
        self.p.x_range.follow = "end"
        self.p.xaxis.axis_label = "Timestamp"
        self.p.x_range.follow_interval = 100
        self.p.x_range.range_padding = 0 
        self.p.line(x="timestamp", y="value", color="blue", source=self.source)
        self.p.circle(x="timestamp", y="value", color="red", source=self.source)

        self.session = push_session(curdoc())
        curdoc().add_periodic_callback(self.update, 100) #period in ms

        self.session.show(column(self.p)) 
        curdoc().title = 'Sensor' 
        self.session.loop_until_closed()

    # def register(self, d, sourceq):
    #     source = ColumnDataSource(dict(d))
    #     self.p.line(x=d[0], y=d[1], color="orange", source=source)
    #     curdoc().add_periodic_callback(self.update, 100) #period in ms 
开发者ID:mpi-sws-rse,项目名称:thingflow-python,代码行数:23,代码来源:bokeh.py

示例10: modify_doc

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
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") 
开发者ID:pythonstock,项目名称:stock,代码行数:23,代码来源:tornado_bokeh_embed.py

示例11: test_bokehplot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
def test_bokehplot():
    fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
    years = ['2015', '2016', '2017']

    data = {'fruits': fruits,
            '2015': [2, 1, 4, 3, 2, 4],
            '2016': [5, 3, 3, 2, 4, 6],
            '2017': [3, 2, 4, 4, 5, 3]}

    x = [(fruit, year) for fruit in fruits for year in years]
    counts = sum(zip(data['2015'], data['2016'], data['2017']), ())  # like an hstack

    source = ColumnDataSource(data=dict(x=x, counts=counts))

    fig = figure(x_range=FactorRange(*x), plot_height=350, title="Fruit Counts by Year",
                 toolbar_location=None, tools="")
    fig.vbar(x='x', top='counts', width=0.9, source=source)
    return BokehPlotBlock(fig) 
开发者ID:man-group,项目名称:PyBloqs,代码行数:20,代码来源:test_image.py

示例12: get_analyzers_tables

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
def get_analyzers_tables(self, analyzer: bt.analyzers.Analyzer, table_width) -> (Paragraph, List[DataTable]):
        """Return a header for this analyzer and one *or more* data tables."""
        if hasattr(analyzer, 'get_analysis_table'):
            title, table_columns_list = analyzer.get_analysis_table()
        else:
            # Analyzer does not provide a table function. Use our generic one
            title, table_columns_list = TableGenerator._get_analysis_table_generic(analyzer)

        param_str = get_params_str(analyzer.params)
        if len(param_str) > 0:
            title += f' ({param_str})'

        elems: List[DataTable] = []
        for table_columns in table_columns_list:
            cds = ColumnDataSource()
            columns = []
            for i, c in enumerate(table_columns):
                col_name = f'col{i}'
                cds.add(c[2:], col_name)
                columns.append(TableColumn(field=col_name, title=c[0], formatter=self._get_formatter(c[1])))
            column_height = len(table_columns[0]) * 25
            elems.append(DataTable(source=cds, columns=columns, index_position=None, width=table_width, height=column_height))
        return Paragraph(text=title, style={'font-size': 'large'}), elems 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:25,代码来源:datatable.py

示例13: __init__

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
def __init__(self, strategy: bt.Strategy, cds: ColumnDataSource, hoverc: HoverContainer, start, end, scheme, master, plotorder, is_multidata):
        self._strategy = strategy
        self._cds: ColumnDataSource = cds
        self._scheme = scheme
        self._start = start
        self._end = end
        self.figure: figure = None
        self._hover_line_set = False
        self._hover: Optional[HoverTool] = None
        self._hoverc = hoverc
        self._coloridx = collections.defaultdict(lambda: -1)
        self.master = master
        self.plottab = None
        self.plotorder = plotorder
        self.datas = []  # list of all datas that have been plotted to this figure
        self._is_multidata = is_multidata
        self._tradingdomain = None
        self._init_figure() 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:20,代码来源:figureenvelope.py

示例14: update_source

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
def update_source(self):
        df = pd.read_csv(StringIO(self.get_relevant_data()), delimiter='\t', header=None, names=['url', 'timestamp'])
        df['domain'] = df['url'].apply(self.extract_tld)
        df1 = df.groupby(['domain']).size()

        df = pd.read_csv(StringIO(self.get_crawled_data()), delimiter='\t', header=None, names=['url', 'timestamp'])
        df['domain'] = df['url'].apply(self.extract_tld)
        df2 = df.groupby(['domain']).size()

        df = pd.concat((df1, df2), axis=1)
        df.columns = ['relevant', 'crawled']

        df = df.sort(self.sort, ascending=False).head(25).fillna(value=0)

        for col in df.columns:
            df['%s_half' % col] = df[col] / 2

        df.reset_index(inplace=True)

        df.rename(columns={'index':'domain'}, inplace=True)

        source = into(ColumnDataSource, df)
        return source 
开发者ID:nasa-jpl-memex,项目名称:memex-explorer,代码行数:25,代码来源:domain.py

示例15: update_source

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import ColumnDataSource [as 别名]
def update_source(self):
        proc = subprocess.Popen(shlex.split("tail -n 800 %s" % self.harvest_data),
                                stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        stdout, stderr = proc.communicate()

        if stderr or not stdout:
            raise ValueError("harvestinfo.csv is empty")

        # Converts stdout to StringIO to allow pandas to read it as a file

        df = pd.read_csv(StringIO(stdout), delimiter='\t',
                         names=['relevant_pages', 'downloaded_pages', 'timestamp'])
        df['harvest_rate'] = df['relevant_pages'] / df['downloaded_pages']
        df['timestamp'] = pd.to_datetime(df['timestamp'], unit='s')

        source = into(ColumnDataSource, df)
        return source 
开发者ID:nasa-jpl-memex,项目名称:memex-explorer,代码行数:20,代码来源:harvest.py


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