function [hfig, hax] = grt_plotfit_st(fitps,fM,label,dbtype,xpt) % function [hfig, hax] = grt_plotfit(fitps,fM,label,dbtype,xpt) % % fitps = output structure from grtfit % xpt = string indicating the experiment: pxt, fxd, mbr, pbr % dbtype = 'linear','piecewise', NOT 'maxpost' % label = string to appear in top left of main subplot % n = index to pick out which set of parameters from fitps to use % i.e., fitps(1).whatever will be plotted bounds = 1; % if bounds, plot bounds in addition to contours lw = 2; %linewidth mrg = 1; %plot marginals fit = 1; %plot pred-obs scatter if length(fitps) > 1 error('please give me a single set of parameters, please.') end m = [fitps(1).maa fitps(1).mab fitps(1).mba fitps(1).mbb]; c = zeros(2,2,4); c(:,:,1) = fitps(1).caa; c(:,:,2) = fitps(1).cab; c(:,:,3) = fitps(1).cba; c(:,:,4) = fitps(1).cbb; if strcmp(dbtype,'maxpost') dbp(1,:) = [fitps.waa fitps.wab fitps.wba fitps.wbb]; else dbp(1,:) = [0 0 fitps.cx fitps.dx 0]; dbp(2,:) = [0 0 fitps.cy fitps.dy 0]; end [nstim,nresp,nbr] = size(fM); % bin widths bin = .05; [dist,x,y] = bivar_norm(m,c,bin,1); lenx = length(x); leny = length(y); xlims = [x(1) x(lenx)]; ylims = [y(1) y(leny)]; if strcmp(dbtype,'maxpost') dec = dec_reg(dbtype,dist,x,y,dbp,nbr); else [dbx,dby] = bound_spec(dbp,x,y,dbtype,nbr); end level = [.08 .08]; % determines the single contour to plot minax = -2.5; maxax = 4.5; hfig = figure; if mrg || fit subplot('Position',[.3 .3 .65 .65]) end hax = gca; pbaspect([1 1 1]) hold on set(hax,'XTick',[],'YTick',[]); for id = 1:nstim [crap,h] = contour(x,y,dist(:,:,id),level); set(h,'EdgeColor',[0 0 0],'LineWidth',lw) end plot(m(1,:),m(2,:),'k+','MarkerSize',10) hax = gca; set(hax,'XLim', xlims, 'YLim', ylims) if ~strcmp(label,[]) text(x(5),y(end-10),label,'FontName','Times','FontSize',16); end if strcmp(dbtype,'linear') || strcmp(dbtype,'piecewise') if bounds plot(x,dbx(2,:),'k','LineWidth',lw)%,'Color',[1 0 0]) plot(dby(2,:),y,'k','LineWidth',lw)%,'Color',[0 0 1]) end elseif strcmp(dbtype,'maxpost') if bounds for is = 1:4 [crap,h] = contour(x,y,dec(:,:,is,3),[.5 .5]); set(h,'EdgeColor',[0 0 0],'LineWidth',lw); end end end if strcmp(xpt,'pxt') xlabel('low - [f0] - high') ylabel('low - [spectral prominence] - high') elseif strcmp(xpt,'fxd') xlabel('low - [freq.] - high') ylabel('short - [dur.] - long') elseif strcmp(xpt,'mbr') text(xlims(1)+abs(.2*xlims(1)),ylims(1)+abs(.2*ylims(1)),'p','FontSize',14) text(xlims(1)+abs(.2*xlims(1)),ylims(2)-abs(.1*ylims(2)),'b','FontSize',14) text(xlims(2)-abs(.2*xlims(2)),ylims(1)+abs(.2*ylims(1)),'f','FontSize',14) text(xlims(2)-abs(.2*xlims(2)),ylims(2)-abs(.1*ylims(2)),'v','FontSize',14) xlabel('stop fricative','FontSize',14) ylabel('voiceless voiced','FontSize',14) elseif strcmp(xpt,'pbr') text(xlims(1)+abs(.2*xlims(1)),ylims(1)+abs(.2*ylims(1)),'p','FontSize',14) text(xlims(1)+abs(.2*xlims(1)),ylims(2)-abs(.1*ylims(2)),'b','FontSize',14) text(xlims(2)-abs(.2*xlims(2)),ylims(1)+abs(.2*ylims(1)),'t','FontSize',14) text(xlims(2)-abs(.2*xlims(2)),ylims(2)-abs(.1*ylims(2)),'d','FontSize',14) %text(0,0,'p','FontSize',14) xlabel('labial coronal','FontSize',14) ylabel('voiceless voiced','FontSize',14) end % [crap,h] = contour(x,y,dist(:,:,3),level); % set(h,'EdgeColor',[1 0 0],'LineWidth',lw) % [crap,h] = contour(x,y,dist(:,:,4),level); % set(h,'EdgeColor',[0 0 1],'LineWidth',lw) xtm = m(1,:); xtv = ones(1,4); ytm = m(2,:); ytv = ones(1,4); for i = 1:4 xdif = xtm(i) == xtm; for j = 1:4 if xdif(j)==1 & i