whiskers.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """Whisker plot with quantiles indication
  2. (horizontal line shows the mean value)"""
  3. from vedo import np, settings, Axes, Brace, Line, Ribbon, show
  4. from vedo.pyplot import whisker
  5. settings.default_font = "Theemim"
  6. # build some theoretical expectation to be shown as a grey band
  7. x = np.linspace(-1, 9, 100)
  8. y = x/5 + 0.2*np.sin(x)
  9. ye= y**2/5 + 0.1 # error on y
  10. line = Line(np.c_[x, y])
  11. band = Ribbon(np.c_[x, y-ye], np.c_[x, y+ye]).c('black',0.1)
  12. # create 5 whisker bars with some random data
  13. ws = []
  14. for i in range(5):
  15. xval = i*2 # position along x axis
  16. data = xval/5 + 0.2*np.sin(xval) + np.random.randn(25)
  17. w = whisker(data, bc=i, s=0.5).x(xval)
  18. ws.append(w)
  19. # print(i, 'whisker:\n', w.info)
  20. # build braces to inndicate stats significance and dosage
  21. bra1 = Brace([0, 3],[2, 3], comment='*~*', s=0.7, style='[')
  22. bra2 = Brace([4,-1],[8,-1], comment='dose > 3~:mug/kg', s=0.4)
  23. # build custom axes
  24. axes = Axes(xrange=[-1,9],
  25. yrange=[-3,5],
  26. htitle=':beta_c expression: change in time',
  27. xtitle=' ',
  28. ytitle='Level of :beta_c protein in :muM/l',
  29. x_values_and_labels=[(0,'Experiment^A\n at t=1h'),
  30. (4,'Experiment^B\n at t=2h'),
  31. (8,'Experiment^C\n at t=4h'),
  32. ],
  33. xlabel_size=0.02,
  34. xygrid=False,
  35. )
  36. show(ws, bra1, bra2, line, band, __doc__, axes, zoom=1.3).close()