-
Notifications
You must be signed in to change notification settings - Fork 0
/
interactive_plot.py
49 lines (43 loc) · 1.58 KB
/
interactive_plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from bokeh.plotting import figure, output_file, show, ColumnDataSource
from bokeh.models import HoverTool
from numpy import random
output_file("interactive_plot.html")
source = ColumnDataSource(
data=dict(
x=random.randint(100, size=(9)),
y=random.randint(100, size=(9)),
desc=['ADINAZOLAM', 'ALPRAZOLAM', 'BROMAZEPAM', 'CHLORDIAZEPOXIDE', 'CLOBAZAM',
'CLONAZEPAM', 'CLORAZEPATE_MONOPOTASSIUM', 'DELORAZEPAM', 'DEMOXEPAM'],
imgs = [
'resources/images/ADINAZOLAM.png',
'resources/images/ALPRAZOLAM.png',
'resources/images/BROMAZEPAM.png',
'resources/images/CHLORDIAZEPOXIDE.png',
'resources/images/CLOBAZAM.png',
'resources/images/CLONAZEPAM.png',
'resources/images/CLORAZEPATE_MONOPOTASSIUM.png',
'resources/images/DELORAZEPAM.png',
'resources/images/DEMOXEPAM.png',
]
)
)
hover = HoverTool(
tooltips="""
<div>
<div>
<img
src="@imgs" height="200" alt="@imgs" width="200"
style="float: left; margin: 15px 15px 15px 15px;"
border="0"
></img>
</div>
<div>
<span style="font-size: 14px; font-weight: bold;">@desc</span>
</div>
</div>
"""
)
p = figure(plot_width=600, plot_height=600, tools=[hover],
title="Interactive plot")
p.circle('x', 'y', size=20, source=source)
show(p)