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


Python Session.use_doc方法代码示例

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


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

示例1: init_plot

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
def init_plot(crawl_name):
    session = Session()
    document = Document()
    session.use_doc(crawl_name)
    session.load_document(document)

    if document.context.children:
        plot = document.context.children[0]
    else:
        output_server(crawl_name)
        # TODO: Remove these when Bokeh is upgraded
        # placeholders or Bokeh can't inject properly
        current = np.datetime64(datetime.now())
        xdr = Range1d(current, current + 1)
        ydr = ["urls"]

        # styling suggested by Bryan
        plot = figure(title="Crawler Monitor", tools="hover",
                      x_axis_type="datetime", y_axis_location="right", x_range=xdr, y_range=ydr,
                      width=1200, height=600)
        plot.toolbar_location = None
        plot.xgrid.grid_line_color = None

    document.add(plot)
    session.store_document(document)
    script = autoload_server(plot, session)

    #TODO: Looks like a Bokeh bug, probably not repeatable with current code
    script = script.replace("'modelid': u'", "'modelid': '")
    return script
开发者ID:vuquangtin,项目名称:memex-explorer,代码行数:32,代码来源:stream.py

示例2: wrapper

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
        def wrapper(*args, **kwargs):
            document = Document()
            session = Session(name=url, root_url=url)
            session.use_doc(document.docid)
            session.load_document(document)
            session.publish()
            document.autoadd = False
            document.autostore = False

            obj = func(*args, **kwargs)
            obj._docid = session.docid
            obj._root_url = session.root_url

            document.add(obj)
            session.store_document(document)
            return obj
开发者ID:DataVizi,项目名称:pycon_2015_bokeh_talk,代码行数:18,代码来源:utils.py

示例3: wrapper

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
        def wrapper(*args, **kwargs):
            docname = prefix + str(uuid.uuid4())
            session = Session(name=url, root_url=url)
            session.use_doc(docname)
            session.load_document(curdoc())
            curdoc().autoadd = False
            curdoc().autostore = False

            obj = func(*args, **kwargs)
            tag = embed.autoload_server(obj, session)
            obj.tag = tag

            curdoc().add(obj)
            changed = session.store_document(curdoc())

            logger.debug("stored: %s", str(changed))

            return obj
开发者ID:Afey,项目名称:bokeh,代码行数:20,代码来源:pluginutils.py

示例4: Document

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
from __future__ import print_function

import numpy as np

from bokeh.models import ColumnDataSource, DataRange1d, Plot, Circle, VBox, HBox, Button, TapTool
from bokeh.document import Document
from bokeh.session import Session
from bokeh.browserlib import view

document = Document()
session = Session()
session.use_doc("linked_tap_server")
session.load_document(document)

N = 9

x = np.linspace(-2, 2, N)
y = x ** 2

source1 = ColumnDataSource(dict(x=x, y=y, size=[20] * N))
xdr1 = DataRange1d()
ydr1 = DataRange1d()
plot1 = Plot(title="Plot1", x_range=xdr1, y_range=ydr1, plot_width=400, plot_height=400)
plot1.tools.append(TapTool(plot=plot1))
plot1.add_glyph(source1, Circle(x="x", y="y", size="size", fill_color="red"))

source2 = ColumnDataSource(dict(x=x, y=y, color=["blue"] * N))
xdr2 = DataRange1d()
ydr2 = DataRange1d()
plot2 = Plot(title="Plot2", x_range=xdr2, y_range=ydr2, plot_width=400, plot_height=400)
plot2.tools.append(TapTool(plot=plot2))
开发者ID:naveenkulkarni,项目名称:bokeh,代码行数:33,代码来源:linked_tap_server.py

示例5: meropenem

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
from collections import OrderedDict

import glob

porins = [_.split("/")[1].split("_")[0] for _ in glob.glob("more_sequences/op*_fasta.fa") ]

MICcols = ["MIC meropenem (ug/ml)", "MIC doripenem (ug/ml)", "MIC ceftazidime (ug/ml)", "MIC piperacillin/tazobactam (ug/ml)",
            "MIC cefepime (ug/ml)", "MIC aztreonam (ug/ml)"]

sortBy = MICcols[0]
porin = "oprD"

document = Document()
session = Session(load_from_config=False)
session.use_doc('porin_map_server')
session.load_document(document)

source = ColumnDataSource(data=dict())
source2 = ColumnDataSource(data=dict())

#Load the meta information
df = pd.read_csv("mastersheet_porin_pics_sorting_data.txt", sep="\t")

allowedStrains = ["ARC" + str(_) for _ in df["Isolate"]]

strains = []
seqLength = 0

def update_data():
开发者ID:caryan,项目名称:PyBio,代码行数:31,代码来源:porin_map.py

示例6: Document

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
from __future__ import print_function

from bokeh.objects import ColumnDataSource
from bokeh.widgetobjects import TableColumn, HandsonTable, PivotTable, HBox
from bokeh.document import Document
from bokeh.session import Session
from bokeh.sampledata.autompg import autompg

document = Document()
session = Session()
session.use_doc('data_tables_server')
session.load_document(document)

source = ColumnDataSource(autompg)

fields = zip(autompg.columns, map(str, autompg.dtypes))
columns = [ TableColumn(data=column, type="text" if dtype == "object" else "numeric", header=column) for column, dtype in fields ]

data_table = HandsonTable(source=source, columns=columns)
pivot_table = PivotTable(source=source, fields=[ dict(name=field, dtype=dtype) for field, dtype in fields ])

hbox = HBox(children=[data_table, pivot_table])

document.add(hbox)
session.store_document(document)

if __name__ == "__main__":
    link = session.object_link(document._plotcontext)
    print("Please visit %s to see the plots" % link)
开发者ID:B-Rich,项目名称:bokeh,代码行数:31,代码来源:data_tables_server.py

示例7: DashBoard

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
class DashBoard(object):

    def __init__(self):
        self.document = Document()
        self.session = Session()
        self.session.use_doc('crawler_dashboard')
        self.session.load_document(self.document)

        #self.harvest_source = ColumnDataSource(data=dict())
        #self.domain_relevant_source = ColumnDataSource(data=dict())
        #self.domain_crawled_source = ColumnDataSource(data=dict())
        #self.domain_frontier_source = ColumnDataSource(data=dict())
        #self.handson_source = ColumnDataSource(data=dict())
        #self.termite_source = ColumnDataSource(data=dict())

        self.harvest = Harvest()
        self.domain = Domain()
        #handson = Handson()
        self.termite = Termite()

        self.document.add(self.create_layout())
        self.session.store_document(self.document)

    def render(self):
        self.create_layout()
        self.document.add(self.layout)
        self.update_data()

    def create_layout(self):

        #button = Button(label="Randomize data", type="success")
        #button.on_click(update_data)
        #top_panel = HBox(children=[button, self.harvest.plot, self.harvest.rate_plot])
        top_panel = HBox(children=[self.harvest.plot, self.harvest.rate_plot])
        domains = VBox(children=[self.domain.sort_relevant_plot, self.domain.sort_crawled_plot, self.domain.sort_frontier_plot], width=200)   
        #middle_panel = HBox(children=[domains, handson.plot])
        middle_panel = HBox(children=[domains])
        layout = VBox(children=[top_panel, middle_panel, self.termite.plot])
        self.layout = layout
        return layout

    def update_data(self):

        self.harvest.source = self.harvest.update_source()
        self.domain.sort_relevant_source, self.domain.sort_crawled_source, self.domain.sort_frontier_source = self.domain.update_source()
        self.termite.data, self.termite.source = self.termite.update_source()
        #self.session.store_objects(ds)
        self.session.store_document(self.document)

        
    def run(self, poll_interval=0.5):
        #link = self.session.object_link(self.document.context)
        #print("Please visit %s to see the plots (press ctrl-C to exit)" % link)

        try:
            while True:
                self.update_data()
                self.session.load_document(self.document)
                time.sleep(poll_interval)
        except KeyboardInterrupt:
            print()
        except ConnectionError:
            print("Connection to bokeh-server was terminated")
开发者ID:ViDA-NYU,项目名称:memex,代码行数:65,代码来源:app.py

示例8: import

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
from __future__ import print_function

from bokeh.browserlib import view
from bokeh.document import Document
from bokeh.session import Session
from bokeh.models.widgets import (
    VBox, Icon,
    Button, Toggle, Dropdown,
    CheckboxGroup, RadioGroup,
    CheckboxButtonGroup, RadioButtonGroup,
)

document = Document()
session = Session()
session.use_doc('buttons_server')
session.load_document(document)

def button_handler():
    print("button_handler: click")
    session.store_document(document)

def toggle_handler(active):
    print("toggle_handler: %s" % active)
    session.store_document(document)

def dropdown_handler(action):
    print("dropdown_handler: %s" % action)
    session.store_document(document)

def split_handler(action):
    print("split_handler: %s" % action)
开发者ID:CatherineH,项目名称:bokeh,代码行数:33,代码来源:buttons_server.py

示例9: DataTables

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
class DataTables(object):

    def __init__(self):
        self.document = Document()
        self.session = Session()
        self.session.use_doc('data_tables_server')
        self.session.load_document(self.document)

        self.manufacturer_filter = None
        self.model_filter = None
        self.transmission_filter = None
        self.drive_filter = None
        self.class_filter = None

        self.source = ColumnDataSource()
        self.update_data()

        self.document.add(self.create())
        self.session.store_document(self.document)

    def create(self):
        manufacturers = sorted(mpg["manufacturer"].unique())
        models = sorted(mpg["model"].unique())
        transmissions = sorted(mpg["trans"].unique())
        drives = sorted(mpg["drv"].unique())
        classes = sorted(mpg["class"].unique())

        manufacturer_select = Select(title="Manufacturer:", value="All", options=["All"] + manufacturers)
        manufacturer_select.on_change('value', self.on_manufacturer_change)
        model_select = Select(title="Model:", value="All", options=["All"] + models)
        model_select.on_change('value', self.on_model_change)
        transmission_select = Select(title="Transmission:", value="All", options=["All"] + transmissions)
        transmission_select.on_change('value', self.on_transmission_change)
        drive_select = Select(title="Drive:", value="All", options=["All"] + drives)
        drive_select.on_change('value', self.on_drive_change)
        class_select = Select(title="Class:", value="All", options=["All"] + classes)
        class_select.on_change('value', self.on_class_change)

        columns = [
            TableColumn(field="manufacturer", header="Manufacturer", type="autocomplete", source=manufacturers),
            TableColumn(field="model", header="Model", type="autocomplete", source=models),
            TableColumn(field="displ", header="Displacement", type="numeric", format="0.00"),
            TableColumn(field="year", header="Year", type="numeric"),
            TableColumn(field="cyl", header="Cylinders", type="numeric"),
            TableColumn(field="trans", header="Transmission", type="dropdown", strict=True, source=transmissions),
            TableColumn(field="drv", header="Drive", type="autocomplete", strict=True, source=drives),
            TableColumn(field="class", header="Class", type="autocomplete", strict=True, source=classes),
            TableColumn(field="cty", header="City MPG", type="numeric"),
            TableColumn(field="hwy", header="Highway MPG", type="numeric"),
        ]
        handson_table = HandsonTable(source=self.source, columns=columns, sorting=True)

        xdr = DataRange1d(sources=[self.source.columns("index")])
        #xdr = FactorRange(factors=manufacturers)
        ydr = DataRange1d(sources=[self.source.columns("cty"), self.source.columns("hwy")])
        plot = Plot(title=None, data_sources=[self.source], x_range=xdr, y_range=ydr, plot_width=800, plot_height=300)
        xaxis = LinearAxis(plot=plot)
        plot.below.append(xaxis)
        yaxis = LinearAxis(plot=plot)
        ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker)
        plot.left.append(yaxis)
        cty = Glyph(data_source=self.source, glyph=Circle(x="index", y="cty", fill_color="green"))
        hwy = Glyph(data_source=self.source, glyph=Circle(x="index", y="hwy", fill_color="red"))
        select_tool = BoxSelectTool(renderers=[cty, hwy], select_y=False)
        plot.tools.append(select_tool)
        overlay = BoxSelectionOverlay(tool=select_tool)
        plot.renderers.extend([cty, hwy, ygrid, overlay])

        controls = VBox(children=[manufacturer_select, model_select, transmission_select, drive_select, class_select], width=200)
        top_panel = HBox(children=[controls, plot])
        layout = VBox(children=[top_panel, handson_table])

        return layout

    def on_manufacturer_change(self, obj, attr, _, value):
        self.manufacturer_filter = None if value == "All" else value
        self.update_data()

    def on_model_change(self, obj, attr, _, value):
        self.model_filter = None if value == "All" else value
        self.update_data()

    def on_transmission_change(self, obj, attr, _, value):
        self.transmission_filter = None if value == "All" else value
        self.update_data()

    def on_drive_change(self, obj, attr, _, value):
        self.drive_filter = None if value == "All" else value
        self.update_data()

    def on_class_change(self, obj, attr, _, value):
        self.class_filter = None if value == "All" else value
        self.update_data()

    def update_data(self):
        df = mpg
        if self.manufacturer_filter:
            df = df[df["manufacturer"] == self.manufacturer_filter]
        if self.model_filter:
            df = df[df["model"] == self.model_filter]
#.........这里部分代码省略.........
开发者ID:akansal1,项目名称:bokeh,代码行数:103,代码来源:data_tables_server.py

示例10: PlottingExtension

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
class PlottingExtension(SimpleExtension):
    """Base class for extensions doing Bokeh plotting.

    Parameters
    ----------
    document_name : str
        The name of the Bokeh document. Use a different name for each
        experiment if you are storing your plots.
    start_server : bool, optional
        Whether to try and start the Bokeh plotting server. Defaults to
        ``False``. The server started is not persistent i.e. after shutting
        it down you will lose your plots. If you want to store your plots,
        start the server manually using the ``bokeh-server`` command. Also
        see the warning above.
    server_url : str, optional
        Url of the bokeh-server. Ex: when starting the bokeh-server with
        ``bokeh-server --ip 0.0.0.0`` at ``alice``, server_url should be
        ``http://alice:5006``. When not specified the default configured
        by ``bokeh_server`` in ``.blocksrc`` will be used. Defaults to
        ``http://localhost:5006/``.
    clear_document : bool, optional
        Whether or not to clear the contents of the server-side document
        upon creation. If `False`, previously existing plots within the
        document will be kept. Defaults to `True`.

    """
    def __init__(self, document_name, server_url=None, start_server=False,
                 clear_document=True, **kwargs):
        self.document_name = document_name
        self.server_url = (config.bokeh_server if server_url is None
                           else server_url)
        self.start_server = start_server
        self.sub = self._start_server_process() if self.start_server else None
        self.session = Session(root_url=self.server_url)
        self.document = Document()
        self._setup_document(clear_document)
        super(PlottingExtension, self).__init__(**kwargs)

    def _start_server_process(self):
        def preexec_fn():
            """Prevents the server from dying on training interrupt."""
            signal.signal(signal.SIGINT, signal.SIG_IGN)
        # Only memory works with subprocess, need to wait for it to start
        logger.info('Starting plotting server on localhost:5006')
        self.sub = Popen('bokeh-server --ip 0.0.0.0 '
                         '--backend memory'.split(),
                         stdout=PIPE, stderr=PIPE, preexec_fn=preexec_fn)
        time.sleep(2)
        logger.info('Plotting server PID: {}'.format(self.sub.pid))

    def _setup_document(self, clear_document=False):
        self.session.use_doc(self.document_name)
        self.session.load_document(self.document)
        if clear_document:
            self.document.clear()
        self._document_setup_done = True

    def __getstate__(self):
        state = self.__dict__.copy()
        state['sub'] = None
        state.pop('session', None)
        state.pop('_push_thread', None)
        return state

    def __setstate__(self, state):
        self.__dict__.update(state)
        if self.start_server:
           self._start_server_process()
        self.session = Session(root_url=self.server_url)
        self._document_setup_done = False

    def do(self, which_callback, *args):
        if not self._document_setup_done:
            self._setup_document()

    @property
    def push_thread(self):
        if not hasattr(self, '_push_thread'):
            self._push_thread = PushThread(self.session, self.document)
            self._push_thread.start()
        return self._push_thread

    def store(self, obj):
        self.push_thread.put(obj, PushThread.PUT)

    def push(self, which_callback):
        self.push_thread.put(which_callback, PushThread.PUSH)
开发者ID:MLDL,项目名称:blocks-extras,代码行数:89,代码来源:plot.py

示例11: import

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
from __future__ import print_function

import numpy as np

from bokeh.browserlib import view
from bokeh.document import Document
from bokeh.glyphs import *
from bokeh.objects import (
    Plot, Range1d, LinearAxis, Grid, ColumnDataSource, PanTool, WheelZoomTool
)
from bokeh.session import Session

document = Document()
session = Session()
session.use_doc('prim_server')
session.load_document(document)

x = np.arange(1,6)
y = np.arange(5, 0, -1)

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

xdr = Range1d(start=0, end=10)
ydr = Range1d(start=0, end=10)

def make_plot(name, glyph):
    plot = Plot(x_range=xdr, y_range=ydr, min_border=80)

    plot.add_glyph(source, glyph)

    xaxis = LinearAxis()
开发者ID:Afey,项目名称:bokeh,代码行数:33,代码来源:prim_server.py

示例12: Document

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
import pandas as pd

from ldadata import data

from bokeh.models import ColumnDataSource, LinearAxis, CategoricalAxis, Plot, DataRange1d, FactorRange, GlyphRenderer, TapTool
from bokeh.models.glyphs import Circle, Text, Rect
from bokeh.models.widgets import TextInput, Button, Slider, HBox, VBox

from bokeh.browserlib import view
from bokeh.document import Document
from bokeh.session import Session
from bokeh.browserlib import view

document = Document()
session = Session()
session.use_doc('ldavis_server')
session.load_document(document)

print("MDSPLOT")

R = data["R"]

mds = pd.DataFrame.from_dict(data["mdsDat"])
lam = pd.DataFrame.from_dict(data["tinfo"])

barDefault2 = lam[lam.Category=="Default"]

mdswidth = 530
mdsheight = 530

circle_prop = 0.25
开发者ID:jimsoros,项目名称:pydata-strata-2014-sj,代码行数:33,代码来源:ldavis.py

示例13: Document

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
source_target_plot = networkx_osm_ops.set_nodes_source_empty()
source_sourcenodes_plot = networkx_osm_ops.set_nodes_source_empty()
source_crit_plot = networkx_osm_ops.set_nodes_source_empty()
source_missing_plot = networkx_osm_ops.set_nodes_source_empty()
source_histo_cum_plot = networkx_osm_ops.set_nodes_source_empty()
source_histo_bin_plot = networkx_osm_ops.set_nodes_source_empty()
source_subgraph_plot = networkx_osm_ops.set_nodes_source_empty()
source_hull_node_plot = networkx_osm_ops.set_nodes_source_empty()
source_hull_patch_plot = networkx_osm_ops.set_nodes_source_empty()
#############

#############    
# CREATE DOCUMENT
document = Document()
session = Session(load_from_config=False)
session.use_doc('Load OSM')
session.load_document(document)
#############

###############################################################################
def define_files():
    '''Define files from root, min_road_type, gmap_background, and indir'''
    
    global root, indir, outroot, outdir, gdelt_infile, osmfile, queryfile, \
                 html_raw, html_ref, html_gdelt, html_aug, \
                 min_road_type, gmap_background

    # output files
    # outroot
    outroot = 'osm_' + root.strip() + '_' + min_road_type.lower()
    # outdir
开发者ID:avanetten,项目名称:bokeh_polygons,代码行数:33,代码来源:gui_init.py

示例14: Population

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
class Population(object):

    year = 2010
    location = "World"

    def __init__(self):
        from bokeh.document import Document
        from bokeh.session import Session
        from bokeh.models import ColumnDataSource
        from bokeh.sampledata.population import load_population

        self.document = Document()
        self.session = Session()
        self.session.use_doc('population')
        self.session.load_document(self.document)

        self.df = load_population()
        self.source_pyramid = ColumnDataSource(data=dict())

    def render(self):
        self.pyramid_plot()
        self.create_layout()
        self.document.add(self.layout)
        self.update_pyramid()

    def pyramid_plot(self):
        from bokeh.models import (
            Plot, DataRange1d, LinearAxis, Grid, Legend,
            SingleIntervalTicker
        )
        from bokeh.models.glyphs import Quad

        xdr = DataRange1d()
        ydr = DataRange1d()

        self.plot = Plot(title=None, x_range=xdr, y_range=ydr,
                         plot_width=600, plot_height=600)

        xaxis = LinearAxis()
        self.plot.add_layout(xaxis, 'below')
        yaxis = LinearAxis(ticker=SingleIntervalTicker(interval=5))
        self.plot.add_layout(yaxis, 'left')

        self.plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
        self.plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))

        male_quad = Quad(left="male", right=0, bottom="groups", top="shifted",
                         fill_color="#3B8686")
        male_quad_glyph = self.plot.add_glyph(self.source_pyramid, male_quad)

        female_quad = Quad(left=0, right="female", bottom="groups", top="shifted",
                           fill_color="#CFF09E")
        female_quad_glyph = self.plot.add_glyph(self.source_pyramid, female_quad)

        self.plot.add_layout(Legend(legends=dict(Male=[male_quad_glyph],
                                                 Female=[female_quad_glyph])))

    def on_year_change(self, obj, attr, old, new):
        self.year = int(new)
        self.update_pyramid()

    def on_location_change(self, obj, attr, old, new):
        self.location = new
        self.update_pyramid()

    def create_layout(self):
        from bokeh.models.widgets import Select, HBox, VBox

        years = list(map(str, sorted(self.df.Year.unique())))
        locations = sorted(self.df.Location.unique())

        year_select = Select(title="Year:", value="2010", options=years)
        location_select = Select(title="Location:", value="World", options=locations)

        year_select.on_change('value', self.on_year_change)
        location_select.on_change('value', self.on_location_change)

        controls = HBox(year_select, location_select)
        self.layout = VBox(controls, self.plot)

    def update_pyramid(self):
        pyramid = self.df[(self.df.Location == self.location) & (self.df.Year == self.year)]

        male = pyramid[pyramid.Sex == "Male"]
        female = pyramid[pyramid.Sex == "Female"]

        total = male.Value.sum() + female.Value.sum()

        male_percent = -male.Value / total
        female_percent = female.Value / total

        groups = male.AgeGrpStart.tolist()
        shifted = groups[1:] + [groups[-1] + 5]

        self.source_pyramid.data = dict(
            groups=groups,
            shifted=shifted,
            male=male_percent,
            female=female_percent,
        )
#.........这里部分代码省略.........
开发者ID:CatherineH,项目名称:bokeh,代码行数:103,代码来源:widget.py

示例15: not

# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import use_doc [as 别名]
va_y = []
for l in va_ys:
    va_y.append([a for a in l if not(math.isnan(a))])

county_nm = pd.Series([us_counties[x]["name"] for x in us_counties if us_counties[x]["state"] == 'va'])

data_counties = pd.DataFrame(index=pd.Series(fips_list))
data_counties = pd.concat([data_counties, raw_df], axis=1)

# getting quantile values for categorising counties
top_qtl = raw_df.quantile(0.66)
middle_qtl = raw_df.quantile(0.33)

session = Session()
document = Document()
session.use_doc('python_project')
session.load_document(document)

source = ColumnDataSource(data=dict(x=[], y=[], c=[], i=[]))
inf_source = ColumnDataSource(data=dict(facs=[]))

# radio buttons intialization
radio = RadioButtonGroup(labels=['Cancer Deaths', 'Heart Disease Deaths', 'Respiratory Disease Deaths', 'Diabetes Deaths'], active=0)
radio.on_click(update)

# calling update function to intialize the plot 
update(0)

        

if __name__ == '__main__':
开发者ID:akshat-verma,项目名称:ChronicDiseaseIndicators,代码行数:33,代码来源:analysis.py


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