Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

histsig.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. function [ hx,xt_sig,x_mean,CI]=histsig(x, x_sig, varargin)
  2. % [ hx]=histsig(x, x_sig, x_lim)
  3. iod = @utils.inputordefault;
  4. hx = iod('ax',[],varargin);
  5. x_lim = iod('x_lim',[],varargin);
  6. num_bns = iod('num_bns',17,varargin);
  7. sig_clr = iod('sig_clr','k',varargin);
  8. org=0.1;
  9. wdth=0.2;
  10. hist_h=0.180;
  11. gd=~isnan(x);
  12. x=x(gd);
  13. x_sig=x_sig(gd);
  14. x_lim_b=[min(x)-0.1 max(x)+0.1];
  15. %x_lim_b = [-1 1];
  16. if nargin==2
  17. x_lim=x_lim_b;
  18. end
  19. if isempty(hx)
  20. figure
  21. hx=axes('Position',[org org wdth hist_h]);
  22. end
  23. marker_size=zeros(size(x))+12;
  24. marker_size(x_sig==1)=24;
  25. % make the x-axis histogram
  26. axes(hx);
  27. bns=linspace(x_lim_b(1),x_lim_b(2),num_bns);
  28. nsig=histc(x(x_sig==0), bns);
  29. nsig=nsig(1:end-1);
  30. sig=histc(x(x_sig==1), bns);
  31. sig=sig(1:end-1);
  32. maxy=max(nsig(:)+sig(:))*1.3;
  33. cbns=edge2cen(bns);
  34. [hh]=bar(cbns, [sig(:) nsig(:)],'stacked');
  35. xlim(x_lim);
  36. set(gca, 'YAxisLocation','left');
  37. set(hh(1),'FaceColor',sig_clr)
  38. set(hh(2),'FaceColor',[1 1 1])
  39. set(gca,'box','off','YLim',[0 maxy])
  40. set(gca,'Color','none')
  41. text(getx,gety,[num2str(round(100*mean(x_sig))) '% p<0.05'])
  42. x_mean=nanmean(x);
  43. [xt_sig,xt_mu,B]=stats.bootmean(x);
  44. [CI]=prctile(B,[2.5 97.5]);
  45. x_se=stats.nanstderr(x);
  46. if xt_sig<0.05
  47. y_lim=ylim(hx);
  48. y_lim=y_lim(2);
  49. hold(hx, 'on')
  50. plot(hx,[x_mean],[0.9*y_lim],'.k','MarkerSize',6);
  51. plot(hx,[CI(1) CI(2)], [0.9*y_lim 0.9*y_lim], '-k');
  52. end
  53. function y=edge2cen(x)
  54. b2b_dist=x(2)-x(1);
  55. y=x+0.5*b2b_dist;
  56. y=y(1:end-1);
  57. function y=getx
  58. x=xlim;
  59. y=0.1*(x(2)-x(1))+x(1);
  60. function y=gety
  61. x=ylim;
  62. y=0.9*(x(2)-x(1))+x(1);