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

时间:2019-08-22 12:34:40

标签: python hover bokeh

我使用bokeh绘制了一个图,此外,我使用了“悬停”工具来查看这些点的值。但我也看到另一个值调用:“ screen”,我想禁用这些值的显示方式

我已经尝试了不同的方法,但是它不起作用

这是我的代码

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)

正如您在此处看到的那样,当我将鼠标停留在具有“数据”和“屏幕”的位置上时,我想禁用显示屏幕部分。enter image description here

2 个答案:

答案 0 :(得分:1)

如果要显示默认工具提示以外的其他内容,则应在pom.xml中指定工具提示。工具提示应指定为(标签,值)元组的列表。以$开头的字段是“特殊字段”,例如字形渲染器的屏幕位置,索引或名称。以@开头的字段与ColumnDataSource中的列相关联。您想要显示数据源中的x / y位置,因此应在工具提示中添加@x和@y。在this页的文档中可以找到有关悬停工具和工具提示的更多信息。

figure()

答案 1 :(得分:0)

这是答案

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)

enter image description here

相关问题