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


Python models.HoverTool类代码示例

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


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

示例1: tagsDistributionScatterPlot

def tagsDistributionScatterPlot(NbTags, dates, plotname='Tags Distribution Plot'):

    output_file(plotname + ".html")

    counts = {}
    glyphs = {}
    desc = {}
    hover = HoverTool()
    plot = figure(plot_width=800, plot_height=800, x_axis_type="datetime", x_axis_label='Date', y_axis_label='Number of tags', tools=[hover])

    for name in NbTags.keys():
        desc[name] = []
        for date in dates[name]:
            desc[name].append(date_tools.datetimeToString(date, "%Y-%m-%d"))
        counts[name] = plot.circle(dates[name], NbTags[name], legend="Number of events with y tags", source=ColumnDataSource(
            data=dict(
                desc=desc[name]
                )
            ))
        glyphs[name] = counts[name].glyph
        glyphs[name].size = int(name) * 2
        hover.tooltips = [("date", "@desc")]
        if int(name) != 0:
            glyphs[name].fill_alpha = 1/int(name)
    show(plot)
开发者ID:3c7,项目名称:PyMISP,代码行数:25,代码来源:bokeh_tools.py

示例2: __init__

    def __init__(self, **kwargs):
        data = self.processing_update({'processing': {}, 'ncores': {}})
        self.source = ColumnDataSource(data)

        x_range = Range1d(-1, 1)
        fig = figure(
            title='Processing and Pending', tools='resize',
             x_range=x_range, id='bk-processing-stacks-plot', **kwargs)
        fig.quad(source=self.source, left=0, right='right', color=Spectral9[0],
                 top='top', bottom='bottom')

        fig.xaxis.minor_tick_line_alpha = 0
        fig.yaxis.visible = False
        fig.ygrid.visible = False

        hover = HoverTool()
        fig.add_tools(hover)
        hover = fig.select(HoverTool)
        hover.tooltips = """
        <div>
            <span style="font-size: 14px; font-weight: bold;">Host:</span>&nbsp;
            <span style="font-size: 10px; font-family: Monaco, monospace;">@name</span>
        </div>
        <div>
            <span style="font-size: 14px; font-weight: bold;">Processing:</span>&nbsp;
            <span style="font-size: 10px; font-family: Monaco, monospace;">@processing</span>
        </div>
        """
        hover.point_policy = 'follow_mouse'

        self.root = fig
开发者ID:dask,项目名称:distributed,代码行数:31,代码来源:components.py

示例3: createBokehChart

    def createBokehChart(self):
        keyFields = self.getKeyFields()
        valueFields = self.getValueFields()
        color = self.options.get("color")
        xlabel = keyFields[0]
        ylabel = valueFields[0]

        wpdf = self.getWorkingPandasDataFrame().copy()
        colors = self.colorPalette(None if color is None else len(wpdf[color].unique()))
        
        p = figure(y_axis_label=ylabel, x_axis_label=xlabel)

        for i,c in enumerate(list(wpdf[color].unique())) if color else enumerate([None]):
            wpdf2 = wpdf[wpdf[color] == c] if c else wpdf
            p.circle(list(wpdf2[xlabel]), list(wpdf2[ylabel]), color=colors[i], legend=str(c) if c and self.showLegend() else None, fill_alpha=0.5, size=8)


        p.xaxis.axis_label = xlabel
        p.yaxis.axis_label = ylabel
        p.legend.location = "top_left"

        hover = HoverTool()
        hover.tooltips = [(xlabel, '@x'), (ylabel, '@y')]
        p.add_tools(hover)

        return p
开发者ID:ibm-cds-labs,项目名称:pixiedust,代码行数:26,代码来源:bkScatterPlotDisplay.py

示例4: lineChart

        def lineChart(df, xlabel, vFields, color=None, clustered=None, title=None):
            ylabel = ','.join(v for v in vFields)
            x = list(df[xlabel].values)
            if df[xlabel].dtype == object:
                p = figure(y_axis_label=ylabel, x_axis_label=xlabel, title=title, x_range=x, **self.get_common_figure_options())
            else:
                p = figure(y_axis_label=ylabel, x_axis_label=xlabel, title=title, **self.get_common_figure_options())

            if clustered is not None:
                colors = self.colorPalette(len(df[clustered].unique())) if color is None else color
                df[clustered] = df[clustered].astype(str)

                for j,c in enumerate(list(df[clustered].unique())) if clustered else enumerate([None]):
                    df2 = df[df[clustered] == c] if c else df
                    df2 = df2.drop(clustered, axis=1) if c else df2

                    for i,v in enumerate(vFields):
                        y = list(df2[v].values)
                        l = v if self.isSubplot() else c
                        p.line(x, y, line_width=2, color=colors[i] if self.isSubplot() else colors[j], legend=l if self.showLegend() else None)
            else:
                colors = self.colorPalette(len(vFields)) if color is None else color
                

                for i,v in enumerate(vFields):
                    y = list(df[v].values)
                    p.line(x, y, line_width=2, color=colors[i], legend=v if self.showLegend() else None)

            p.legend.location = "top_left"

            hover = HoverTool()
            hover.tooltips = [(xlabel, '@x'), (ylabel, '@y{0.00}'), ('x', '$x'), ('y', '$y')]
            p.add_tools(hover)

            return p
开发者ID:ibm-cds-labs,项目名称:pixiedust,代码行数:35,代码来源:bkLineChartDisplay.py

示例5: __init__

    def __init__(self, scheduler, **kwargs):
        with log_errors():
            self.scheduler = scheduler
            self.source = ColumnDataSource({'occupancy': [0, 0],
                                            'worker': ['a', 'b'],
                                            'x': [0.0, 0.1],
                                            'y': [1, 2],
                                            'ms': [1, 2]})

            fig = figure(title='Occupancy', tools='resize', id='bk-occupancy-plot',
                         x_axis_type='datetime', **kwargs)
            fig.rect(source=self.source, x='x', width='ms', y='y', height=1,
                     color='blue')

            fig.xaxis.minor_tick_line_alpha = 0
            fig.yaxis.visible = False
            fig.ygrid.visible = False
            # fig.xaxis[0].formatter = NumeralTickFormatter(format='0.0s')
            fig.x_range.start = 0

            hover = HoverTool()
            hover.tooltips = "@worker : @occupancy s"
            hover.point_policy = 'follow_mouse'
            fig.add_tools(hover)

            self.root = fig
开发者ID:dask,项目名称:distributed,代码行数:26,代码来源:scheduler.py

示例6: data_usage_plot

def data_usage_plot(df):
    def create_data_source(df):
        return ColumnDataSource(data=dict(filesystem=df['filesystem'],total_size=df['total_size'],used=df['used'],available=df['available'],use_percent=df['use_percent'],mounted=['mounted'],submittime=[x.strftime("%Y-%m-%d") for x in df['submittime']]))

    hover = HoverTool(names=['points'])
    TOOLS = [BoxZoomTool(),PanTool(),ResetTool(),WheelZoomTool(),hover]
    Colors = ['red','navy','olive','firebrick','lightskyblue','yellowgreen','lightcoral','yellow', 'green','blue','gold']

    # Change percents to format bokeh can use
    fp_list = []
    for row in df['use_percent']:
        fp_list.append(float(row.replace('%','')))
    df['f_percent'] = fp_list

    # Begin Plotting
    x_max = datetime.now()
    p = figure(height=500, width=1000, x_axis_type="datetime", x_range=((x_max-timedelta(14)),x_max), y_axis_label='Percent Full', tools=TOOLS, title='Data Usage by Filesystem')

    # Points with hover info
    p.scatter(x=df['submittime'], y=df['f_percent'], name='points', source=create_data_source(df), color='black', size=6)
    df = df.groupby(by = ['filesystem'])

    # Connecting lines
    count = 0
    for filesystem, group in df:
        count += 1
        p.line(x=group['submittime'] ,y=group['f_percent'], color=Colors[count], legend=str(filesystem), line_width=3)

    # Formating
    p.legend.orientation = "top_left"
    hover.point_policy = "follow_mouse"
    hover.tooltips = [("Filesystem", "@filesystem"),("Size","@total_size"),("Available","@available"),("Percent Used","@use_percent"),("Time","@submittime")]

    return p
开发者ID:DarkEnergySurvey,项目名称:desdm-dash,代码行数:34,代码来源:plotter.py

示例7: nbytes_plot

def nbytes_plot(**kwargs):
    data = {"name": [], "left": [], "right": [], "center": [], "color": [], "percent": [], "MB": [], "text": []}
    source = ColumnDataSource(data)
    fig = figure(title="Memory Use", tools="", toolbar_location=None, id="bk-nbytes-plot", **kwargs)
    fig.quad(source=source, top=1, bottom=0, left="left", right="right", color="color", alpha=1)

    fig.grid.grid_line_color = None
    fig.grid.grid_line_color = None
    fig.axis.visible = None
    fig.outline_line_color = None

    hover = HoverTool()
    fig.add_tools(hover)
    hover = fig.select(HoverTool)
    hover.tooltips = """
    <div>
        <span style="font-size: 14px; font-weight: bold;">Name:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@name</span>
    </div>
    <div>
        <span style="font-size: 14px; font-weight: bold;">Percent:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@percent</span>
    </div>
    <div>
        <span style="font-size: 14px; font-weight: bold;">MB:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@MB</span>
    </div>
    """
    hover.point_policy = "follow_mouse"

    return source, fig
开发者ID:broxtronix,项目名称:distributed,代码行数:31,代码来源:status_monitor.py

示例8: plot_lines

def plot_lines(df, fig, x, y, group):
    legends = []
    groups = df.groupby(by=[group])
    numlines = len(groups)
    colors=Spectral11[0:numlines]
    for i, (key, grp) in enumerate(groups):
        grp = grp.sort_values(by=x,axis=0)
        name = str(key)
        source = ColumnDataSource(data=grp)
        line = fig.line(x, y,  source=source, line_width=4, line_color=colors[i])
        point = fig.circle(x, y,  source=source, name=name, size=8, fill_color=colors[i])
        legends.append((name, [line]))

        hover = HoverTool(names=[name])
        hover.tooltips = [(c, '@' + c) for c in grp.columns]
        hover.tooltips.append(('index', '$index'))
        fig.add_tools(hover)

    # place a legend outside the plot area
    # http://bokeh.pydata.org/en/dev/docs/user_guide/styling.html#outside-the-plot-area
    legend = Legend(legends=legends, location=(0, -30), name="foppo")

    fig.add_layout(legend, 'right')


    return fig
开发者ID:cswarth,项目名称:santa-perf,代码行数:26,代码来源:plot_bokeh.py

示例9: nbytes_plot

def nbytes_plot(**kwargs):
    data = {'name': [], 'left': [], 'right': [], 'center': [], 'color': [],
            'percent': [], 'MB': [], 'text': []}
    source = ColumnDataSource(data)
    fig = figure(title='Memory Use', tools='', toolbar_location=None, **kwargs)
    fig.quad(source=source, top=1, bottom=0,
             left='left', right='right', color='color', alpha=0.8)
    fig.text(source=source, x='center', y=0.5, text='text',
             text_baseline='middle', text_align='center')

    fig.grid.grid_line_color = None
    fig.grid.grid_line_color = None
    fig.axis.visible = None
    fig.outline_line_color = None

    hover = HoverTool()
    fig.add_tools(hover)
    hover = fig.select(HoverTool)
    hover.tooltips = """
    <div>
        <span style="font-size: 14px; font-weight: bold;">Name:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@name</span>
    </div>
    <div>
        <span style="font-size: 14px; font-weight: bold;">Percent:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@percent</span>
    </div>
    <div>
        <span style="font-size: 14px; font-weight: bold;">MB:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@MB</span>
    </div>
    """
    hover.point_policy = 'follow_mouse'

    return source, fig
开发者ID:martindurant,项目名称:distributed,代码行数:35,代码来源:status_monitor.py

示例10: make_plot

def make_plot(yscale='linear'):
    # configure the tools
    width_zoom={'dimensions':['width']}
    tools = [tool(**width_zoom) for tool in [BoxZoomTool, WheelZoomTool]]

    hover_pos = HoverTool(
            names=['buy','sell'],
            tooltips=[
              ('Position','@pos'),
              ('Date','@date'),
              ('Price','@price')
            ]
    )
    hover_pos.name = 'Postions'


    tools.extend([PanTool(), hover_pos, ResetTool(), CrosshairTool()])

    # prepare plot
    p = Figure(plot_height=600, plot_width=800, title="Moving Average Positions",
            x_axis_type='datetime', y_axis_type=yscale, tools=tools)

    p.line(x='date', y='price', alpha=0.3, color='Black', line_width=2, source=source, legend='Close', name='price')
    p.line(x='date', y='mav_short', color='DarkBlue', line_width=2, source=source, legend='Short MAV')
    p.line(x='date', y='mav_long', color='FireBrick', line_width=2, source=source, legend='Long MAV')
    p.inverted_triangle(x='x', y='y', color='Crimson', size=20, alpha=0.7, source=sell, legend='Sell', name='sell')
    p.triangle(x='x', y='y', color='ForestGreen', size=20, alpha=0.7, source=buy, legend='Buy', name='buy')

    return p
开发者ID:AlbertDeFusco,项目名称:stocksDashboard,代码行数:29,代码来源:stocks-dashboard.py

示例11: task_stream_plot

def task_stream_plot(sizing_mode="scale_width", **kwargs):
    data = {
        "start": [],
        "duration": [],
        "key": [],
        "name": [],
        "color": [],
        "worker": [],
        "y": [],
        "worker_thread": [],
        "alpha": [],
    }

    source = ColumnDataSource(data)
    x_range = DataRange1d(range_padding=0)

    fig = figure(
        x_axis_type="datetime",
        title="Task stream",
        tools="xwheel_zoom,xpan,reset,box_zoom",
        toolbar_location="above",
        sizing_mode=sizing_mode,
        x_range=x_range,
        id="bk-task-stream-plot",
        **kwargs
    )
    fig.rect(
        x="start",
        y="y",
        width="duration",
        height=0.8,
        fill_color="color",
        line_color="color",
        line_alpha=0.6,
        alpha="alpha",
        line_width=3,
        source=source,
    )
    fig.xaxis.axis_label = "Time"
    fig.yaxis.axis_label = "Worker Core"
    fig.ygrid.grid_line_alpha = 0.4
    fig.xgrid.grid_line_color = None
    fig.min_border_right = 35
    fig.yaxis[0].ticker.num_minor_ticks = 0

    hover = HoverTool()
    fig.add_tools(hover)
    hover = fig.select(HoverTool)
    hover.tooltips = """
    <div>
        <span style="font-size: 12px; font-weight: bold;">@name:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@duration</span>
        <span style="font-size: 10px;">ms</span>&nbsp;
    </div>
    """
    hover.point_policy = "follow_mouse"

    return source, fig
开发者ID:broxtronix,项目名称:distributed,代码行数:58,代码来源:status_monitor.py

示例12: worker_table_plot

def worker_table_plot(**kwargs):
    """ Column data source and plot for host table """
    with log_errors():
        # names = ['host', 'cpu', 'memory_percent', 'memory', 'cores', 'processes',
        #          'processing', 'latency', 'last-seen', 'disk-read', 'disk-write',
        #          'network-send', 'network-recv']
        names = ['processes', 'disk-read', 'cores', 'cpu', 'disk-write',
                 'memory', 'last-seen', 'memory_percent', 'host']
        source = ColumnDataSource({k: [] for k in names})

        columns = {name: TableColumn(field=name,
                                     title=name.replace('_percent', ' %'))
                   for name in names}

        cnames = ['host', 'cores', 'processes', 'memory', 'cpu', 'memory_percent']

        formatters = {'cpu': NumberFormatter(format='0.0 %'),
                      'memory_percent': NumberFormatter(format='0.0 %'),
                      'memory': NumberFormatter(format='0 b'),
                      'latency': NumberFormatter(format='0.00000'),
                      'last-seen': NumberFormatter(format='0.000'),
                      'disk-read': NumberFormatter(format='0 b'),
                      'disk-write': NumberFormatter(format='0 b'),
                      'net-send': NumberFormatter(format='0 b'),
                      'net-recv': NumberFormatter(format='0 b')}

        table = DataTable(source=source, columns=[columns[n] for n in cnames],
                          **kwargs)
        for name in cnames:
            if name in formatters:
                table.columns[cnames.index(name)].formatter = formatters[name]

        x_range = Range1d(0, 1)
        y_range = Range1d(-.1, .1)
        mem_plot = figure(title="Memory Usage (%)",
                          tools='box_select', height=90, width=600,
                          x_range=x_range, y_range=y_range, toolbar_location=None)
        mem_plot.circle(source=source, x='memory_percent', y=0, size=10,
                        alpha=0.5)
        mem_plot.yaxis.visible = False
        mem_plot.xaxis.minor_tick_line_width = 0
        mem_plot.ygrid.visible = False
        mem_plot.xaxis.minor_tick_line_alpha = 0

        hover = HoverTool()
        mem_plot.add_tools(hover)
        hover = mem_plot.select(HoverTool)
        hover.tooltips = """
        <div>
          <span style="font-size: 10px; font-family: Monaco, monospace;">@host: </span>
          <span style="font-size: 10px; font-family: Monaco, monospace;">@memory_percent</span>
        </div>
        """
        hover.point_policy = 'follow_mouse'

    return source, [mem_plot, table]
开发者ID:amosonn,项目名称:distributed,代码行数:56,代码来源:worker_monitor.py

示例13: progress_plot

def progress_plot(height=300, width=800, **kwargs):
    from ..diagnostics.progress_stream import progress_quads
    data = progress_quads({'all': {}, 'in_memory': {},
                           'erred': {}, 'released': {}})

    source = ColumnDataSource(data)
    fig = figure(width=width, height=height, tools=['resize'],
                 responsive=True, **kwargs)
    fig.quad(source=source, top='top', bottom='bottom',
             left=0, right=1, color='#aaaaaa', alpha=0.2)
    fig.quad(source=source, top='top', bottom='bottom',
             left=0, right='released_right', color='#0000FF', alpha=0.4)
    fig.quad(source=source, top='top', bottom='bottom',
             left='released_right', right='in_memory_right',
             color='#0000FF', alpha=0.8)
    fig.quad(source=source, top='top', bottom='bottom',
             left='erred_left', right=1,
             color='#000000', alpha=0.3)
    fig.text(source=source, text='fraction', y='center', x=-0.01,
             text_align='right', text_baseline='middle')
    fig.text(source=source, text='name', y='center', x=1.01,
             text_align='left', text_baseline='middle')
    fig.scatter(x=[-0.2, 1.4], y=[0, 5], alpha=0)
    fig.xgrid.grid_line_color = None
    fig.ygrid.grid_line_color = None
    fig.axis.visible = None
    fig.min_border_left = 0
    fig.min_border_right = 10
    fig.min_border_top = 0
    fig.min_border_bottom = 0
    fig.outline_line_color = None

    hover = HoverTool()
    fig.add_tools(hover)
    hover = fig.select(HoverTool)
    hover.tooltips = """
    <div>
        <span style="font-size: 14px; font-weight: bold;">Name:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@name</span>
    </div>
    <div>
        <span style="font-size: 14px; font-weight: bold;">All:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@all</span>
    </div>
    <div>
        <span style="font-size: 14px; font-weight: bold;">In Memory:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@in_memory</span>
    </div>
    <div>
        <span style="font-size: 14px; font-weight: bold;">Erred:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@erred</span>
    </div>
    """
    hover.point_policy = 'follow_mouse'

    return source, fig
开发者ID:coobas,项目名称:distributed,代码行数:56,代码来源:status_monitor.py

示例14: progress_plot

def progress_plot(**kwargs):
    from ..diagnostics.progress_stream import progress_quads
    data = progress_quads({'all': {}, 'in_memory': {},
                           'erred': {}, 'released': {}})

    x_range = Range1d(-0.5, 1.5)
    y_range = Range1d(5.1, -0.1)
    source = ColumnDataSource(data)
    fig = figure(tools='', toolbar_location=None, y_range=y_range, x_range=x_range, **kwargs)
    fig.quad(source=source, top='top', bottom='bottom',
             left=0, right=1, color='#aaaaaa', alpha=0.2)
    fig.quad(source=source, top='top', bottom='bottom',
             left=0, right='released_right', color=Spectral9[0], alpha=0.4)
    fig.quad(source=source, top='top', bottom='bottom',
             left='released_right', right='in_memory_right',
             color=Spectral9[0], alpha=0.8)
    fig.quad(source=source, top='top', bottom='bottom',
             left='erred_left', right=1,
             color='#000000', alpha=0.3)
    fig.text(source=source, text='fraction', y='center', x=-0.01,
             text_align='right', text_baseline='middle')
    fig.text(source=source, text='name', y='center', x=1.01,
             text_align='left', text_baseline='middle')
    fig.xgrid.grid_line_color = None
    fig.ygrid.grid_line_color = None
    fig.axis.visible = None
    fig.outline_line_color = None

    hover = HoverTool()
    fig.add_tools(hover)
    hover = fig.select(HoverTool)
    hover.tooltips = """
    <div>
        <span style="font-size: 14px; font-weight: bold;">Name:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@name</span>
    </div>
    <div>
        <span style="font-size: 14px; font-weight: bold;">All:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@all</span>
    </div>
    <div>
        <span style="font-size: 14px; font-weight: bold;">In Memory:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@in_memory</span>
    </div>
    <div>
        <span style="font-size: 14px; font-weight: bold;">Erred:</span>&nbsp;
        <span style="font-size: 10px; font-family: Monaco, monospace;">@erred</span>
    </div>
    """
    hover.point_policy = 'follow_mouse'

    return source, fig
开发者ID:HugoTian,项目名称:distributed,代码行数:52,代码来源:status_monitor.py

示例15: _draw_contigCirclePlot

    def _draw_contigCirclePlot(self):
        hover = HoverTool(tooltips=[('Length', '@contigs')])
        hover.point_policy = "follow_mouse"
        plot = figure(x_axis_type=None, y_axis_type=None, tools=[hover], title='Contig lengths')
        plot.annular_wedge(x=0, y=0, inner_radius=0.5, outer_radius=0.7,
                           start_angle='start', end_angle='stop',
                           color='colors', alpha=0.9, source=self.contig_dist_src)
        plot.yaxis.axis_label_text_font_size = '14pt'
        plot.xaxis.axis_label_text_font_size = '14pt'
        plot.yaxis.major_label_text_font_size = '14pt'
        plot.xaxis.major_label_text_font_size = '14pt'
        plot.title.text_font_size = '16pt'

        return plot
开发者ID:emilhaegglund,项目名称:schavott,代码行数:14,代码来源:UI.py


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