當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。