% This script plots arrows between the populations in showConnMulti.m % x_po, y_po: Coordinates of the post-population % x_pr, y_pr: Coordinates of the pre-population % an : Angle of inclination % x0, y0 : Coordinates of arrow shaft % x1, y1 : Coordinates of arrow point % x2, y2 : Coordinates of arrowhead right corner % x3, y3 : Coordinates of arrowhead left corner % For auto-arrow % x4, y4, x5, y5, x6, y6, etc: Other arrow points %Arrowhead w2 = pi/6; r2 = 0.05; w3 = -pi/6; r3 = 0.05; for iiiii = 1:length( arrows ) x_po = pop( arrows(iiiii).post ).x; y_po = pop( arrows(iiiii).post ).y; if arrows(iiiii).pre == arrows(iiiii).post % self connection d = 0.025; an = abs( arrows(iiiii).labpos ); r = pop( arrows(iiiii).post ).radius; [x1,y1] = pol2cart(an, r ); x7 = x_po + x1 * sqrt( r*r-d*d ) / r; y7 = y_po + y1 * sqrt( r*r-d*d ) / r; x6 = x7 + 0.1*cos(an); y6 = y7 + 0.1*sin(an); x1 = x7 + d * cos(an+pi/2); y1 = y7 + d * sin(an+pi/2); x0 = x1 + 0.1*cos(an); y0 = y1 + 0.1*sin(an); x4 = x7 - d * cos(an+pi/2); y4 = y7 - d * sin(an+pi/2); x5 = x4 + 0.1*cos(an); y5 = y4 + 0.1*sin(an); line( [x0 x5], [y0 y5] ) line( [x4 x5], [y4 y5] ) elseif arrows(iiiii).pre < 0 % external connection an = abs( arrows(iiiii).pre ); x_pr = x_po + 0.1*cos( an ); y_pr = y_po + 0.1*sin( an ); [x1,y1] = pol2cart(an, pop( arrows(iiiii).post ).radius ); x1 = x1 + x_po; y1 = y1 + y_po; x0 = x1 + 0.1*cos(an); y0 = y1 + 0.1*sin(an); else % arrow between populations x_pr = pop( arrows(iiiii).pre).x; y_pr = pop( arrows(iiiii).pre).y; if x_pr == x_po an = pi/2+pi*(y_po>y_pr); else an = atan( (y_pr-y_po)/(x_pr-x_po) ); end if x_pr 1/10000 xxx(iiiii) = x1 + (yyy(iiiii)-y1)/(tan(an)); else xxx(iiiii) = x1 + (yyy(iiiii)-y1)*1e10; end end if mod( kant+d, 4 ) == 0 if yyy(iiiii) > y2+ht yyy(iiiii) = y2; dud = dud*(-1); end elseif mod( kant+d, 4 ) == 1 if xxx(iiiii) < x2-wt xxx(iiiii) = x2; dlr = dlr * (-1); end elseif mod( kant+d, 4 ) == 2 if yyy(iiiii) < y2-ht yyy(iiiii) = y2; dud = dud * (-1); end elseif mod( kant+d, 4 ) == 3 if xxx(iiiii) > x2+wt xxx(iiiii) = x2; dlr = dlr * (-1); end end end if dlr > 0 hstr = 'right'; else hstr = 'left'; end if dud > 0 vstr = 'bottom'; else vstr = 'top'; end end arrrr = arrows; i = 1; while length(xxx)>0 curr = find(xxx == xxx(1) & yyy == yyy(1)); currlab = [arrrr(curr(1)).label]; for i = 2:length(curr) currlab = [currlab ', ' arrrr(curr(i)).label]; end txxt(i) = text( xxx(1), yyy(1), currlab, ... 'HorizontalAlignment', hstr, 'VerticalAlignment', vstr ); xxx(curr) = []; yyy(curr) = []; arrrr(curr) = []; i = i + 1; end set( gca, 'FontSize', 14 )