简体   繁体   English

如何删除散景中悬停通行费的“屏幕信息”?

[英]how can I remove the “screen information” of hover tolls in bokeh?

I have drawn a plot using bokeh, moreover, I have used the "hover" tool to see the value of the points. 此外,我已经使用bokeh绘制了一个图,并且使用了“悬停”工具来查看这些点的值。 but I see also another value calls: "screen" I want to kind of disable the presentation of these values 但我也看到另一个值调用:“ screen”,我想禁用这些值的显示

I already tried different ways, but It doesnot work 我已经尝试了不同的方法,但是没有用

here is my code 这是我的代码

tools = ["hover","crosshair","box_select","box_zoom","wheel_zoom","reset"]
            p = figure(title=self.select_recension, width=1000, height=800, x_range=(1.5, 22), y_range=(35.5, 47),tools=tools)
            for i in self.fs_dict.values():
                p.line(i[:,0],i[:,1], color="dodgerblue",legend="Boundary in Omega",line_width=1.5)
            co="dfTemp"
            p.circle(np.array(self.df_dict[co]['longitude']),np.array(self.df_dict[co]['latitude']), fill_color="dodgerblue",size=6,fill_alpha=.9,line_color="dodgerblue",line_alpha=0.6,legend="Localities in Omega",muted_alpha=0.2)
            for i in self.gs_dict.values():
                p.line(i[:,0],i[:,1], color="red",legend="Boundary in Xi",line_dash="dashdot",line_width=1.5)
            co='dfTempX'
            p.circle(np.array(self.df_dict[co]['longitude']),np.array(self.df_dict[co]['latitude']), fill_color="crimson",size=6, fill_alpha=.9, line_color="red",line_alpha=0.6,legend="Localities in Xi")
            p.legend.click_policy="hide"
            show(p)

As you see here when I keep my mouse on the point I have "data" and "screen" I want to disable showing screen part. 如您在此处看到的,当我将鼠标放在该点上时,我具有“数据”和“屏幕”,我想禁用显示屏幕部分。 在此处输入图片说明

You should specify the tooltips in figure() if you want to show something else than the default tooltips. 如果要显示默认工具提示以外的其他内容,则应在figure()指定工具提示。 The tooltips should be specified as a list of (label, value) tuples. 工具提示应指定为(标签,值)元组的列表。 Fields that start with a $ are 'special fields' such as the screen location, index or name of the glyph renderer. 以$开头的字段是“特殊字段”,例如字形渲染器的屏幕位置,索引或名称。 Fields that start with a @ are associated with columns in the ColumnDataSource. 以@开头的字段与ColumnDataSource中的列相关联。 You want to show the x/y position that is in the datasource so you should add @x and @y to your tooltips. 您想要显示数据源中的x / y位置,因此应在工具提示中添加@x和@y。 More information about hovertools and tooltips can be found in the documentation on this page. 有关hovertools和工具提示的更多信息,可以在页面的文档中找到。

from bokeh.plotting import figure, output_file, show, ColumnDataSource

output_file("toolbar.html")

source = ColumnDataSource(data=dict(
    x=[1, 2, 3, 4, 5],
    y=[2, 5, 8, 2, 7],
    desc=['A', 'b', 'C', 'd', 'E'],
))

TOOLTIPS = [
    ("index", "$index"),
    ("(x,y)", "($x, $y)"),
    ("desc", "@desc"),
]

p = figure(plot_width=400, plot_height=400, tooltips=TOOLTIPS, title="Mouse over the dots", tools="pan,wheel_zoom,hover,reset")

p.circle('x', 'y', size=20, source=source)

show(p)

here is the answer 这是答案

def plot_recension(self,fs_dict,gs_dict,df_dict,select_recension):

        """This function returns the map based on the entered values as follows:
        fs_dic ~ dictionary of  coastal localities in Omega  -->dict
        gs_dict ~dictionary of  coastal localities in Xi  -->dict
        df_dic ~ dictionary of all localities -->dict
        select_recension ~ either 'Omega ' or -'Xi '  -->string
        pay attention to capitalization 
        """
        tools = ["hover","box_select","box_zoom","wheel_zoom","reset"]
        TOOLTIPS = [("index", "$index"),("(x,y)", "($x, $y)")]
        p = figure(title=self.select_recension, width=1000, height=800, x_range=(1.5, 22), y_range=(35.5, 47),tooltips=TOOLTIPS,tools=tools)
        p.background_fill_color = "beige"
        p.background_fill_alpha = 0.5
        if select_recension== 'Omega':
            Locality={"x":list(self.df_dict["dfTemp"]['longitude']),"y":list(self.df_dict["dfTemp"]['latitude'])}
            source = ColumnDataSource(data=Locality)
            view = CDSView(source=source)
            for i in self.fs_dict.values():
                p.line(i[:,0],i[:,1], color="black",legend="Boundary in Omega",muted_alpha=0.2)
            co="dfTemp"
            p.circle(x='x', y='y',source=source,view=view, fill_color="blue",size=6,fill_alpha=.9,line_color="blue",line_alpha=0.6,legend="Localities in Omega ",muted_alpha=0.2)
        elif select_recension== 'Xi':
            Locality={"x":list(self.df_dict["dfTempX"]['longitude']),"y":list(self.df_dict["dfTempX"]['latitude'])}
            source = ColumnDataSource(data=Locality)
            view = CDSView(source=source)
            for i in self.gs_dict.values():
                p.line(i[:,0],i[:,1], color="black",legend="Boundary in Xi ",muted_alpha=0.2,line_dash="dashdot")
            co='dfTempX'
            p.circle(np.array(self.df_dict[co]['longitude']),np.array(self.df_dict[co]['latitude']), fill_color="red",size=6, fill_alpha=.9, line_color="red",line_alpha=0.6,legend="Localities in Xi",muted_alpha=0.2)
        p.legend.click_policy="mute"
        show(p)

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从屏幕中删除信息并重新使用在该屏幕上显示信息的方法? Kivy、Python(已编辑) - How can I remove information from the screen and reuse the method of displaying information on this screen? Kivy, Python (Edited) 如何在散景悬停格式化程序上设置自定义日期时间模式? - How can I set custom datetime pattern on Bokeh hover formatter? 在散景中,如何显示点和面块的不同信息? - In Bokeh, how can I display different information for points and patches? 在python的散景中,如何删除绘图上方的文本? - In python's Bokeh, how can I remove text above the plot? 如何从散景 plot 中删除网格边框? - How can I remove the grid border from a Bokeh plot? 如何自定义散景中的悬停 - How to customize hover in bokeh 如何在 HoloViews plot 上添加关于节点的可变数量的自定义 hover 字段? (python 和散景后端) - How can I add a variable number of custom hover fields, with respect to node, on a HoloViews plot? (python and bokeh backend) 散景悬停工具提示:如何在图形上看不到零值? - Bokeh hover tooltips: How do I not see values that are zero on a graph? 如何将悬停突出显示添加到散景步骤图 - How do I add hover highlighting to Bokeh Step Chart 如何在散景烛台图表中添加 hover 工具(python) - How do i add hover tool in a bokeh candlestick chart (python)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM