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


Python models.HoverTool方法代码示例

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


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

示例1: make_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [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

示例2: make_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [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

示例3: make_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [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

示例4: __init__

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [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

示例5: createHoverTool

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [as 别名]
def createHoverTool():
    
    """
    Helper function to create family hover preview
    
    """
    
    hover = HoverTool(
        tooltips="""
        <div>
        <div>
            <img src="./clusters/@famnum.png" style="height: 100px; width: 500px;
                vertical-align: middle;" />
            <span style="font-size: 9px; font-family: Helvetica;">Cluster ID: </span>
            <span style="font-size: 12px; font-family: Helvetica;">@famnum</span>
        </div>
        </div>
        """, names=["patch"])

    return hover 
开发者ID:ahotovec,项目名称:REDPy,代码行数:22,代码来源:plotting.py

示例6: location_plot

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [as 别名]
def location_plot(title, colors):
    output_file(title+".html")
    location_source = ColumnDataSource(
        data={
            "x": whisky[" Latitude"],
            "y": whisky[" Longitude"],
            "colors": colors,
            "regions": whisky.Region,
            "distilleries": whisky.Distillery
        }
    )
    
    fig = figure(title = title,
        x_axis_location = "above", tools="resize, hover, save")
    fig.plot_width  = 400
    fig.plot_height = 500
    fig.circle("x", "y", 10, 10, size=9, source=location_source,
         color='colors', line_color = None)
    fig.xaxis.major_label_orientation = np.pi / 3
    hover = fig.select(dict(type = HoverTool))
    hover.tooltips = {
        "Distillery": "@distilleries",
        "Location": "(@x, @y)"
    }
    show(fig) 
开发者ID:prateekiiest,项目名称:Code-Sleep-Python,代码行数:27,代码来源:code.py

示例7: _add_hover_tool

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [as 别名]
def _add_hover_tool(plot, point_glyph, df):
    top_cols = ["model", "name", "value"]
    optional_cols = ["model_class", "conf_int_lower", "conf_int_upper"]
    for col in optional_cols:
        if len(df[col].unique()) > 1:
            top_cols.append(col)
    tooltips = [(col, "@" + col) for col in top_cols]
    hover = HoverTool(renderers=[point_glyph], tooltips=tooltips)
    plot.tools.append(hover) 
开发者ID:OpenSourceEconomics,项目名称:estimagic,代码行数:11,代码来源:comparison_plot.py

示例8: apply_hovertips

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [as 别名]
def apply_hovertips(self, figures: List['FigureEnvelope']) -> None:
        """Add hovers to to all figures from the figures list"""
        for f in figures:
            for t in f.figure.tools:
                if not isinstance(t, HoverTool):
                    continue

                self._apply_to_figure(f, t)
                break 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:11,代码来源:figureenvelope.py

示例9: create

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [as 别名]
def create(self):
        self.source = self.update_source()

        p = figure(plot_width=400, plot_height=400,
                   title="Harvest Plot", x_axis_type='datetime',
                   tools='pan, wheel_zoom, box_zoom, reset, resize, save, hover')

        p.line(x="timestamp", y="relevant_pages", color=GREEN, line_width=0.2,
               legend="relevant", source=self.source)
        p.scatter(x="timestamp", y="relevant_pages", fill_alpha=0.6,
                  color=GREEN, source=self.source)

        p.line(x="timestamp", y="downloaded_pages", color=DARK_GRAY, line_width=0.2,
               legend="downloaded", source=self.source)
        p.scatter(x="timestamp", y="downloaded_pages", fill_alpha=0.6,
                 color=DARK_GRAY, source=self.source)

        hover = p.select(dict(type=HoverTool))
        hover.tooltips = OrderedDict([
            ("harvest_rate", "@harvest_rate"),
        ])

        p.legend.orientation = "top_left"

        script, div = components(p)
        return (script, div) 
开发者ID:nasa-jpl-memex,项目名称:memex-explorer,代码行数:28,代码来源:harvest.py

示例10: test_hover_tool_instance_renderer_association

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [as 别名]
def test_hover_tool_instance_renderer_association(self):
        tooltips = [("index", "$index")]
        hover = HoverTool(tooltips=tooltips)
        opts = dict(tools=[hover])
        overlay = Curve(np.random.rand(10,2)).opts(plot=opts) * Points(np.random.rand(10,2))
        plot = bokeh_renderer.get_plot(overlay)
        curve_plot = plot.subplots[('Curve', 'I')]
        self.assertEqual(len(curve_plot.handles['hover'].renderers), 1)
        self.assertIn(curve_plot.handles['glyph_renderer'], curve_plot.handles['hover'].renderers)
        self.assertEqual(plot.handles['hover'].tooltips, tooltips) 
开发者ID:holoviz,项目名称:holoviews,代码行数:12,代码来源:testoverlayplot.py

示例11: test_heatmap_custom_string_tooltip_hover

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [as 别名]
def test_heatmap_custom_string_tooltip_hover(self):
        tooltips = "<div><h1>Test</h1></div>"
        custom_hover = HoverTool(tooltips=tooltips)
        hm = HeatMap([(1,1,1), (2,2,0)], kdims=['x with space', 'y with $pecial symbol'])
        hm = hm.options(tools=[custom_hover])
        plot = bokeh_renderer.get_plot(hm)
        hover = plot.handles['hover']
        self.assertEqual(hover.tooltips, tooltips)
        self.assertEqual(hover.renderers, [plot.handles['glyph_renderer']]) 
开发者ID:holoviz,项目名称:holoviews,代码行数:11,代码来源:testheatmapplot.py

示例12: plot_bokeh

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [as 别名]
def plot_bokeh(df,sublist,filename):
    lenlist=[0]
    df_sub = df[df['cuisine']==sublist[0]]
    lenlist.append(df_sub.shape[0])
    for cuisine in sublist[1:]:
        temp = df[df['cuisine']==cuisine]
        df_sub = pd.concat([df_sub, temp],axis=0,ignore_index=True)
        lenlist.append(df_sub.shape[0])
    df_X = df_sub.drop(['cuisine','recipeName'],axis=1)
    print df_X.shape, lenlist

    dist = squareform(pdist(df_X, metric='cosine'))
    tsne = TSNE(metric='precomputed').fit_transform(dist)
    #cannot use seaborn palette for bokeh
    palette =['red','green','blue','yellow']
    colors =[]
    for i in range(len(sublist)):
        for j in range(lenlist[i+1]-lenlist[i]):
            colors.append(palette[i])
    #plot with boken
    output_file(filename)
    source = ColumnDataSource(
            data=dict(x=tsne[:,0],y=tsne[:,1],
                cuisine = df_sub['cuisine'],
                recipe = df_sub['recipeName']))

    hover = HoverTool(tooltips=[
                ("cuisine", "@cuisine"),
                ("recipe", "@recipe")])

    p = figure(plot_width=1000, plot_height=1000, tools=[hover],
               title="flavor clustering")

    p.circle('x', 'y', size=10, source=source,fill_color=colors)

    show(p) 
开发者ID:lingcheng99,项目名称:Flavor-Network,代码行数:38,代码来源:recipe_clustering.py

示例13: getHTML

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [as 别名]
def getHTML(self, params):
        state = params['state']
        if state == 'all':
            data = self.data
        else:
            data = self.data[self.data['state'] == state]

        TOOLS = "pan,wheel_zoom,box_zoom,reset,hover,previewsave"

        try:
            fig = plotting.patches(
                data['lons'], data['lats'], fill_color=data['color'], fill_alpha=0.7, tools=TOOLS,
                line_color="white", line_width=0.5, title=state.upper() + " Unemployment 2009"
            )
        except Exception:
            fig = plotting.figure(title=state.upper() + " Unemployment 2009", tools=TOOLS)
            fig.patches(
                data['lons'], data['lats'], fill_color=data['color'],
                fill_alpha=0.7, line_color="white", line_width=0.5
            )

        hover = fig.select(dict(type=HoverTool))
        hover.tooltips = OrderedDict([
            ("index", "$index")
        ])

        script, div = components(fig, CDN)
        html = "%s\n%s" % (script, div)
        return html 
开发者ID:adamhajari,项目名称:spyre,代码行数:31,代码来源:unemployment_example.py

示例14: make_alignment_figure

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [as 别名]
def make_alignment_figure(src, tgt, alignment, title="Attention Model", toolbar_location='right', plot_width=800, plot_height=800):

    alignment = alignment[:, ::-1]
#     tgt = list(reversed(tgt))

    src = ["%i %s" % (num, x) for num, x in enumerate(src)]
    tgt = ["%s %i" % (x, num) for num, x in reversed(list(enumerate(tgt)))]

    xname = []
    yname = []
    color = []
    alpha = []

    count = []
    for i, n1 in enumerate(src):
        for j, n2 in enumerate(tgt):
            xname.append(n1)
            yname.append(n2)
            alpha.append(alignment[i, j])
            color.append('black')
            count.append(alignment[i, j])

#     for x, y, a in zip(xname, yname, alpha):
#         print(x, y, a)

    source = ColumnDataSource(
        data=dict(
            xname=xname,
            yname=yname,
            colors=color,
            alphas=alpha,
            count=count,
        )
    )

    # create a new figure
    p = figure(title=title,
               x_axis_location="above", tools="hover", toolbar_location=toolbar_location,
               x_range=src, y_range=tgt,
               plot_width=plot_width, plot_height=plot_height)

    p.rect('xname', 'yname', 0.9, 0.9, source=source,
           color='colors', alpha='alphas', line_color=None)

    p.grid.grid_line_color = None
    p.axis.axis_line_color = None
    p.axis.major_tick_line_color = None
    p.axis.major_label_text_font_size = "10pt"
    p.axis.major_label_standoff = 0
    p.xaxis.major_label_orientation = np.pi / 3

    hover = p.select(dict(type=HoverTool))
    hover.tooltips = [
        ('tgt/src', '@yname, @xname'),
        ('attn', '@count'),
    ]

    return p 
开发者ID:fabiencro,项目名称:knmt,代码行数:60,代码来源:visualisation.py

示例15: plot_detection_history

# 需要导入模块: from bokeh import models [as 别名]
# 或者: from bokeh.models import HoverTool [as 别名]
def plot_detection_history():
    # Rectangle grid with detection history
    cols = np.shape(audio.predictions)[1]

    plt = figure(plot_width=WIDTHS[0], plot_height=HEIGHTS[1],
                 toolbar_location=None, tools="hover",
                 x_range=[-cols, 0], y_range=labels[::-1])

    plt.rect(x='x', y='y', width=0.95, height=0.8, color='color', source=HISTORY)

    # X ticks
    plt.xaxis[0].ticker = FixedTicker(ticks=np.arange(-cols, 1, 1).tolist())
    plt.xaxis[0].formatter = FuncTickFormatter(code="""
        return (tick * {} / 1000).toFixed(1) + " s"
    """.format(PREDICTION_STEP_IN_MS))
    plt.xaxis.major_tick_line_color = GRID_COLOR
    plt.xaxis.major_label_text_font_size = '7pt'
    plt.xaxis.major_label_text_font = TEXT_FONT
    plt.xaxis.major_label_text_color = TEXT_COLOR

    # X axis
    plt.xaxis.axis_line_color = None

    # Y ticks
    plt.yaxis.major_tick_line_color = None
    plt.yaxis.major_label_text_font_size = '7pt'
    plt.yaxis.major_label_text_font = TEXT_FONT
    plt.yaxis.major_label_text_color = TEXT_COLOR

    # Y axis
    plt.yaxis.axis_line_color = GRID_COLOR

    # Grid
    plt.ygrid.grid_line_color = None
    plt.xgrid.grid_line_color = None

    # Plot fill/border
    plt.background_fill_color = GRID_COLOR
    plt.outline_line_color = GRID_COLOR
    plt.min_border = 10

    # Plot title
    plt.title.text = 'Detection history:'
    plt.title.align = 'left'
    plt.title.text_color = TEXT_COLOR
    plt.title.text_font = TEXT_FONT
    plt.title.text_font_size = '9pt'
    plt.title.text_font_style = 'normal'

    # Hover tools
    hover = plt.select(dict(type=HoverTool))
    hover.tooltips = [
        ("Event", "@label"),
        ('Probability', '@pretty_value'),
    ]

    return plt 
开发者ID:karolpiczak,项目名称:EARS,代码行数:59,代码来源:main.py


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