-
Notifications
You must be signed in to change notification settings - Fork 265
/
whiskers.py
44 lines (36 loc) · 1.44 KB
/
whiskers.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
"""Whisker plot with quantiles indication
(horizontal line shows the mean value)"""
from vedo import np, settings, Axes, Brace, Line, Ribbon, show
from vedo.pyplot import whisker
settings.default_font = "Theemim"
# build some theoretical expectation to be shown as a grey band
x = np.linspace(-1, 9, 100)
y = x/5 + 0.2*np.sin(x)
ye= y**2/5 + 0.1 # error on y
line = Line(np.c_[x, y])
band = Ribbon(np.c_[x, y-ye], np.c_[x, y+ye]).c('black',0.1)
# create 5 whisker bars with some random data
ws = []
for i in range(5):
xval = i*2 # position along x axis
data = xval/5 + 0.2*np.sin(xval) + np.random.randn(25)
w = whisker(data, bc=i, s=0.5).x(xval)
ws.append(w)
# print(i, 'whisker:\n', w.info)
# build braces to inndicate stats significance and dosage
bra1 = Brace([0, 3],[2, 3], comment='*~*', s=0.7, style='[')
bra2 = Brace([4,-1],[8,-1], comment='dose > 3~:mug/kg', s=0.4)
# build custom axes
axes = Axes(xrange=[-1,9],
yrange=[-3,5],
htitle=':beta_c expression: change in time',
xtitle=' ',
ytitle='Level of :beta_c protein in :muM/l',
x_values_and_labels=[(0,'Experiment^A\n at t=1h'),
(4,'Experiment^B\n at t=2h'),
(8,'Experiment^C\n at t=4h'),
],
xlabel_size=0.02,
xygrid=False,
)
show(ws, bra1, bra2, line, band, __doc__, axes, zoom=1.3).close()