1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- function [ hx,xt_sig,x_mean,CI]=histsig(x, x_sig, varargin)
- % [ hx]=histsig(x, x_sig, x_lim)
- iod = @utils.inputordefault;
- hx = iod('ax',[],varargin);
- x_lim = iod('x_lim',[],varargin);
- num_bns = iod('num_bns',17,varargin);
- sig_clr = iod('sig_clr','k',varargin);
- org=0.1;
- wdth=0.2;
- hist_h=0.180;
- gd=~isnan(x);
- x=x(gd);
- x_sig=x_sig(gd);
- x_lim_b=[min(x)-0.1 max(x)+0.1];
- %x_lim_b = [-1 1];
- if nargin==2
- x_lim=x_lim_b;
- end
-
- if isempty(hx)
- figure
- hx=axes('Position',[org org wdth hist_h]);
- end
- marker_size=zeros(size(x))+12;
- marker_size(x_sig==1)=24;
- % make the x-axis histogram
- axes(hx);
- bns=linspace(x_lim_b(1),x_lim_b(2),num_bns);
- nsig=histc(x(x_sig==0), bns);
- nsig=nsig(1:end-1);
- sig=histc(x(x_sig==1), bns);
- sig=sig(1:end-1);
- maxy=max(nsig(:)+sig(:))*1.3;
- cbns=edge2cen(bns);
- [hh]=bar(cbns, [sig(:) nsig(:)],'stacked');
- xlim(x_lim);
- set(gca, 'YAxisLocation','left');
- set(hh(1),'FaceColor',sig_clr)
- set(hh(2),'FaceColor',[1 1 1])
- set(gca,'box','off','YLim',[0 maxy])
- set(gca,'Color','none')
- text(getx,gety,[num2str(round(100*mean(x_sig))) '% p<0.05'])
- x_mean=nanmean(x);
- [xt_sig,xt_mu,B]=stats.bootmean(x);
- [CI]=prctile(B,[2.5 97.5]);
- x_se=stats.nanstderr(x);
- if xt_sig<0.05
- y_lim=ylim(hx);
- y_lim=y_lim(2);
- hold(hx, 'on')
- plot(hx,[x_mean],[0.9*y_lim],'.k','MarkerSize',6);
- plot(hx,[CI(1) CI(2)], [0.9*y_lim 0.9*y_lim], '-k');
-
- end
-
- function y=edge2cen(x)
- b2b_dist=x(2)-x(1);
- y=x+0.5*b2b_dist;
- y=y(1:end-1);
- function y=getx
- x=xlim;
- y=0.1*(x(2)-x(1))+x(1);
- function y=gety
- x=ylim;
- y=0.9*(x(2)-x(1))+x(1);
|