Hi folks,
I have two separate custom hover sets in my graph. However, the hover is still showing default hover data [ (index,data(x,y),screen(x,y)] alongside with my custom ones. I don’t want these defaults. Please help.
def visualize_bokeh(self, tail_parameters):
TOOLS = "hover,pan,wheel_zoom,box_zoom,reset,save"
# Creating a Bokeh figure
s1 = figure(x_axis_type="datetime", tools=TOOLS, width=1200, height=300,sizing_mode='stretch_width')
# Setting the y-axis range name and range for Theta
s1.extra_y_ranges['Theta'] = Range1d(start=min(tail_parameters), end=max(tail_parameters))
# Plotting line for the Theta values
line_theta = s1.line(self.data.index[self.window_size:], tail_parameters, width=1,
line_color="black", y_range_name="Theta", legend_label='Theta')
# Adding HoverTool for Theta
hover_theta = HoverTool(renderers=[line_theta], tooltips=[('Date', '@x{%F}'), ('Theta', '@y{0.00}')],
formatters={'@x': 'datetime'})
s1.add_tools(hover_theta)
# Setting the y-axis range name and range for S&P500
s1.extra_y_ranges["S&P500"] = Range1d(start=min(self.data['S&P500'][self.window_size:]),
end=max(self.data['S&P500'][self.window_size:]))
line_snp = s1.line(self.data.index[self.window_size:], self.data['S&P500'][self.window_size:], width=1,
line_color="blue", y_range_name="S&P500", legend_label='S&P500')
# Adding HoverTool for S&P500
hover_snp = HoverTool(renderers=[line_snp], tooltips=[('Date', '@x{%F}'), ('S&P500', '@y{0.00000}')],
formatters={'@x': 'datetime'})
s1.add_tools(hover_snp)
# Adding a separate y-axis for S&P500 with tick colors
s1.add_layout(LinearAxis(y_range_name="S&P500",
major_tick_line_color='blue', minor_tick_line_color='blue',
major_label_text_color='blue'), 'right')
# Show the combined graphs with twin y axes for Theta and S&P500
s1.legend.location = "top_left"
s1.legend.click_policy = "hide" # Clicking on legend hides the corresponding plot
# Display the figure
show(s1)