How to use the bokeh.models.HoverTool function in bokeh

To help you get started, we’ve selected a few bokeh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CIRCL / potiron / potiron / isn-pcap-process-day.py View on Github external
z_input.append(int(dport))
            proc.wait()
            x = np.array(x_input,dtype=np.datetime64)
            z = np.array(z_input)
            y = np.array(y_input)
            w = np.array(w_input)
            colors = [
                "#%02x%02x%02x" % (int(r), int(g), 150) for r, g in zip(50+z*2, 30+z*2)
            ]
            title = "{} collected on {}/{}/{} at {}".format(source, date[0],date[1],date[2],h)
            # Definition of the sequence numbers plot
            p_seq = figure(width=1500, height=700, tools=TOOLS, x_axis_type="datetime", title="TCP sequence values in Honeypot {}".format(title))
            p_seq.xaxis.axis_label = "Time"
            p_seq.yaxis[0].formatter = BasicTickFormatter(use_scientific=False)
            p_seq.scatter(x, y, color=colors, legend="seq values", alpha=0.5, )
            hoverseq = p_seq.select(dict(type=HoverTool))
            hoverseq.tooltips = [
                    ("index", "$index"),
                    ("timestamp", "@x"),
                    ("number", "@y{0,0}")
                    ]
            # Definition of the acknowledgement numbers plot
            p_ack = figure(width=1500, height=700, tools=TOOLS, x_axis_type="datetime", title="TCP acknowledgement values in Honeypot {}".format(title))
            p_ack.xaxis.axis_label = "Time"
            p_ack.yaxis[0].formatter = BasicTickFormatter(use_scientific=False)
            p_ack.scatter(x, w, color=colors, legend="ack values", alpha=0.5, )
            hoverack = p_ack.select(dict(type=HoverTool))
            hoverack.tooltips = [
                    ("index", "$index"),
                    ("timestamp", "@x"),
                    ("number", "@y{0,0}")
                    ]
github PatrikHlobil / Pandas-Bokeh / pandas_bokeh / plot.py View on Github external
x="__x__values",
                y="y",
                text="text",
                text_font_style="bold",
                source=text_source,
            )

            p.line(
                x=[-1.3 - 0.04 * (max_col_stringlength - len(col)), 0],
                y=[0.5 - 0.3 * i, -(inner_radius + outer_radius) / 2],
                line_color="black",
            )

        # Define hovertool and add to Pieplot:
        if hovertool:
            my_hover = HoverTool(renderers=[glyph])
            if hovertool_string is None:
                my_hover.tooltips = [
                    (xlabelname, "@__x__values_original"),
                    (col, "@{%s}" % col),
                ]
            else:
                my_hover.tooltips = hovertool_string
            p.add_tools(my_hover)

    return p
github CIRCL / potiron / potiron / isn-redis-process-day.py View on Github external
print("{} - {}".format(start_hour,end_hour))
                    # Export the plot into a png file
                    if export:
                        export_png(p, filename = "{}/{}.png".format(output_dir,output_name))
        else:
            ports = args.port_filter
            minutes = 0
            # For each period of time corresponding to the timeline
            for nb in range(1,int(occurrence_num_hour+1)):
                start_min = format(minutes, '02d')
                it_minutes = minutes
                start_hour, end_hour = string_timeline(h, start_min, format((minutes+timeline),'02d'))
                title = " {} collected on {} between {} and {}".format(source, date, start_hour, end_hour)
                # Definition of the sequence numbers plot
                p_seq = figure(width=1500,height=700,tools=TOOLS, x_axis_type="datetime", title="TCP sequence values in Honeypot {}".format(title))
                hoverseq = p_seq.select(dict(type=HoverTool))
                hoverseq.tooltips = [
                        ("index", "$index"),
                        ("timestamp", "@x{%F %H:%M:%S}"),
                        ("number", "@y{0,0}")
                        ]
                hoverseq.formatters = {
                        'x': 'datetime'}
                p_seq.xaxis.axis_label = "Time"
                p_seq.yaxis.axis_label = "Sequence Numbers"
                p_seq.yaxis[0].formatter = BasicTickFormatter(use_scientific=False)
                # Definition of the aclnowledgement numbers plot
                p_ack = figure(width=1500,height=700,tools=TOOLS, x_axis_type="datetime", title="TCP acknowledgement values in Honeypot {}".format(title))
                hoverack = p_ack.select(dict(type=HoverTool))
                hoverack.tooltips = [
                        ("index", "$index"),
                        ("timestamp", "@x{%F %H:%M:%S}"),
github lmcinnes / umap / doc / bokeh_digits_plot.py View on Github external
digits_df["image"] = list(map(embeddable_image, digits.images))

datasource = ColumnDataSource(digits_df)
color_mapping = CategoricalColorMapper(
    factors=[str(9 - x) for x in digits.target_names], palette=Spectral10
)

plot_figure = figure(
    title="UMAP projection of the Digits dataset",
    plot_width=600,
    plot_height=600,
    tools=("pan, wheel_zoom, reset"),
)

plot_figure.add_tools(
    HoverTool(
        tooltips="""
<div>
    <div>
        <img style="float: left; margin: 5px 5px 5px 5px" src="@image">
    </div>
    <div>
        <span style="font-size: 16px; color: #224499">Digit:</span>
        <span style="font-size: 18px">@digit</span>
    </div>
</div>
"""
    )
)

plot_figure.circle(
    "x",
github ADEQUATeDQ / portalmonitor / odpw / utils / plots.py View on Github external
x = 1. * arange(len(d)) / (len(d) - 1)
        mx=max(x) if max(x)>mx else mx

        if sn == max(data.keys()):
            ci=bp.circle(x,y, size=5, alpha=0.5,  color='red', legend="current week: "+getWeekString(sn))
            li=bp.line(x,y, line_width=2,line_color='red', legend="current week: "+getWeekString(sn))
        else:
            ci=bp.circle(x,y, size=5, alpha=0.5,  color='gray')
            li=bp.line(x,y, line_width=2,line_color='gray')
            #hit_target =Circle(x,y, size=10,line_color=None, fill_color=None)


            #c.select(dict(type=HoverTool)).tooltips = {"Week": "@week",m:"@"+m.lower()}
            #hit_renderers.append(hit_renderer)

            bp.add_tools(HoverTool(renderers=[li], tooltips={"Week": getWeekString(sn)}))

        c+=1
        #bp.text(,y[-1], line_width=2,line_color=OrRd9[c],legend=str(sn))
        no_olympics_glyph = Text(x=x[-1], y=y[-1], x_offset=100, text=["%s of %s portals"%(len(d), cnts[sn])],
            text_align="right", text_baseline="top",
            text_font_size="9pt", text_font_style="italic", text_color="black")
        bp.add_glyph(no_olympics_glyph)

    bp.x_range=Range1d(0, mx*1.2)
    bp.background_fill_color = "#fafafa"

    bp.legend.location = "top_left"

    return bp
github emilhaegglund / schavott / scavott / staellning.py View on Github external
def contig_circle():
    """ Create contig circle. """
    hover = HoverTool(tooltips=[
                ('Length', '@contigs')])
    hover.point_policy = "follow_mouse"
    plot = figure(x_axis_type=None, y_axis_type=None, tools=[hover])
    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=contig_src)
    plot.title = 'Contig lengths'
    return plot
github ChairOfStructuralMechanicsTUM / Mechanics_Apps / Shock_Response_Spectra / main.py View on Github external
fig.line(x=[-2,2],y=[.75,.75],color="black",line_width=3)
fig.multi_line(xs=[[-2.75,-2],[-1.75,-1.0],[-0.75,0],[.25,1],[1.25,2]],
    ys=[[0,0.75],[0,0.75],[0,0.75],[0,0.75],[0,0.75]],
    color="black",
    line_width=3)
fig.line(x='x',y='y',source=Bottom_Line,color="black",line_width=3)
fig.line(x='x',y='y',source=Linking_Line,color="black",line_width=3)
fig.toolbar.logo = None
glob_vars["spring"].plot(fig,width=2)
glob_vars["damper"].plot(fig,width=2)
glob_vars["mass"].plot(fig)
arrow = fig.add_layout(Arrow(end=NormalHead(fill_color="red"), line_color="red", line_width=2,
    x_start='x1', y_start='y1', x_end='x2', y_end='y2', source=arrow_line))

# time plot
hover = HoverTool(tooltips=[("time","@t s"), ("displacement","@s m")])
Displacement = figure(title="", y_range=(2,-2), x_range=Range1d(bounds=(0,1000), start=0, end=20), height=550, \
    toolbar_location="right", tools=[hover,"ywheel_zoom,xwheel_pan,pan,reset"]) #ywheel_zoom,xwheel_pan,reset,
Displacement.line(x='t',y='s',source=displacement,color="#e37222",line_width=2,legend="Total Displacement",muted_color="#e37222",muted_alpha=0.2)
Displacement.axis.major_label_text_font_size="12pt"
Displacement.axis.axis_label_text_font_style="normal"
Displacement.axis.axis_label_text_font_size="14pt"
Displacement.xaxis.axis_label="Time [s]"
Displacement.yaxis.axis_label="Displacement [u/(F/k)]"
Displacement.legend.location="top_right"
Displacement.legend.click_policy="mute"
Displacement.toolbar.logo = None


#maximum displacement against time of impulse to time period ratio plot
Dis_max = figure(title="", tools="", x_range=(0,3.0), y_range=(0,4), width=600, height=600)
Dis_max.circle(x='time', y='omega', source=omega_max, color="#a2ad00")
github nasa-jpl-memex / memex-explorer / source / apps / crawl_space / viz / harvest.py View on Github external
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)
github dask / distributed / distributed / dashboard / components / scheduler.py View on Github external
color="black",
            alpha=0.3,
        )
        rect = self.root.square(
            x="x",
            y="y",
            size=10,
            color=node_colors,
            source=self.node_source,
            view=node_view,
            **{"legend_field" if BOKEH_VERSION &gt;= "1.4" else "legend": "state"},
        )
        self.root.xgrid.grid_line_color = None
        self.root.ygrid.grid_line_color = None

        hover = HoverTool(
            point_policy="follow_mouse",
            tooltips="<b>@name</b>: @state",
            renderers=[rect],
        )
        tap = TapTool(callback=OpenURL(url="info/task/@key.html"), renderers=[rect])
        rect.nonselection_glyph = None
        self.root.add_tools(hover, tap)
        self.max_items = config.get("distributed.dashboard.graph-max-items", 5000)
github astrazeneca-cgr-publications / mantis-ml-release / mantis_ml / modules / unsupervised_learn / dimens_reduction.py View on Github external
content=data['Gene_Name'],
            annot=data['annotation'],
        ))

        interact_viz = figure(plot_width=900, plot_height=900,
                              title=method, tools="pan,wheel_zoom,box_zoom,reset,hover,previewsave",
                              x_axis_type=None, y_axis_type=None, min_border=1)

        interact_viz.scatter(x='x', y='y',
                             source=source,
                             color='color',
                             alpha=0.8, size=10,
                             legend=method)

        # hover tools
        hover = interact_viz.select(dict(type=HoverTool))
        hover.tooltips = [("gene", "@content")]
        interact_viz.legend.location = "top_left"

        plot_filename = method + "_interactive_plot.html"
        output_file(str(self.cfg.unsuperv_figs_out / plot_filename))
        save(interact_viz)

        if show_plot:
            show(interact_viz)

        if save_plot:
            interact_viz.output_backend = "svg"
            plot_filename = method + '_interactive_plot.svg'
            export_svgs(interact_viz, filename=(self.cfg.unsuperv_figs_out / plot_filename))