Skip to content

Instantly share code, notes, and snippets.

@tmzhuang
Created July 17, 2020 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmzhuang/426006a514ad84a576fad7f1a58dd230 to your computer and use it in GitHub Desktop.
Save tmzhuang/426006a514ad84a576fad7f1a58dd230 to your computer and use it in GitHub Desktop.
# Show tooltips on test data
hover = HoverTool(
tooltips=[
('Test', '$name'),
('Date', '@created_at_{%F}'),
('Branch', '@branch_'),
('Revision', '@revision_'),
(metric, '@$name{0.0}')],
formatters={
'created_at_': 'datetime', # use 'datetime' formatter for 'date' field
},
)
p = figure(title=f'{gapp_name} historic results',
y_axis_label=f'Mean {metric} ({heuristic} is better)',
x_axis_label='Date',
tools=['pan', 'wheel_zoom', 'box_zoom', hover, 'reset'],
active_scroll='wheel_zoom',
# plot_width=plot_width,
plot_height=plot_height,
x_axis_type='datetime')
# Annotations
annotation_renderers = []
for class_name, model_annotations in annotation_mapping.items():
for model_annotation in model_annotations:
color = 'blue'
alpha = 0.2
span = Span(location=model_annotation.annotation.datetime, dimension='height', line_color=color, line_width=2,
line_alpha=alpha, level='glyph', visible=False)
label = Label(x=model_annotation.annotation.datetime,
y=plot_height/3, y_units='screen', text=str(model_annotation), level='glyph', angle=pi/2,
text_alpha=0.75, visible=False)
annotation_renderers.append(span)
p.add_layout(span)
p.add_layout(label)
p.add_tools(HoverTool(
renderers=annotation_renderers,
tooltips=[
# How do I get annotation data to appear here?
('hi', 'hi'),
]
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment