-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotters.py
More file actions
49 lines (46 loc) · 1.48 KB
/
plotters.py
File metadata and controls
49 lines (46 loc) · 1.48 KB
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
from bokeh.transform import jitter
def cat_dots_plot(categories, dots, title, color='blue', toolbar=None):
p = figure( x_axis_label='participant ID'
, x_range=categories
, y_axis_label='duration (s)'
, height=600
, width=600
, toolbar_location=toolbar
, tools=['ypan', 'crosshair', 'hover', 'ywheel_zoom']
, active_scroll='ywheel_zoom'
, title=title
)
p.circle( x=jitter('x', width=0.6, range=p.x_range)
, y='y'
, color=color
, source=dots
, size=15
, alpha=0.1
)
return p
def make_round_to_nearest(m):
return lambda n: int(m) if n <= m else int(((n // m) + 1) * m)
def duration_histo_plot(yr, durs, binsize, color):
rounder = make_round_to_nearest(binsize)
mind = min(durs)
maxd = max(durs)
y = list(range(rounder(mind), rounder(maxd), binsize))
rounded = [rounder(d) for d in durs]
right = [rounded.count(n) for n in y]
p = figure( x_axis_label='number of mappings'
, y_axis_label='duration (s) [binsize='+str(binsize)+'s]'
, y_range=yr
, height=600
, width=300
, toolbar_location=None
, tools=['ypan', 'crosshair', 'hover', 'ywheel_zoom']
, active_scroll='ywheel_zoom'
)
p.hbar( y=y
, height=10
, right=right
, color=color
, alpha=0.5
)
return p