No BSD License  

Highlights from
meet the family

image thumbnail
from meet the family by nathan q
Visualisation of a family tree in the programming contest.

plotColorAuthor2(entries,multiParents,authorid,x,y)
function [hLines,hDots,aDots] = plotColorAuthor2(entries,multiParents,authorid,x,y)

markers = {'o' '^' 's'};

hLines=zeros(1,numel(entries));
hDots=zeros(1,2*numel(entries));  % overestimate length

authors1=unique(authorid([entries multiParents{entries}]));
cmap=colormap(jet(length(authors1)));

k1=1; k2=1;
for i=entries;
    p = multiParents{i};
    for j=1:numel(p);
        iauthor = find(authors1==authorid(i));
        hLines(k1)= line([x(i) x(p(j))] , [y(i) y(p(j))], 'color',cmap(iauthor,:));
        k1=k1+1;
        hDots(k2) = line(x(i) , y(i) , 'marker', markers{mod(iauthor,3)+1},...
            'color',cmap(iauthor,:), 'markerfacecolor',cmap(iauthor,:) , 'markeredgecolor','black' );
        aDots(k2) = authorid(i);
        k2=k2+1;
        if ~any (p(j)==entries)
            % plot a terminal dot if the parent of p(j) isn't already in the list for plotting
            iauthor = find(authors1==authorid(p(j)));
            hDots(k2) = line(x(p(j)) , y(p(j)) , 'marker', markers{mod(iauthor,3)+1}, 'color',cmap(iauthor,:), 'markerfacecolor',cmap(iauthor,:) , 'markeredgecolor','black');
            aDots(k2) = authorid(p(j));
            k2=k2+1;
        end
    end;
end

hDots = hDots(hDots>0 & ishandle(hDots));
hLines = hLines(hLines>0 & ishandle(hLines));

return

Contact us at files@mathworks.com