[英]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.