MATLAB DATAVIS Contest
Entry for the Spring 2009 MATLAB Data Visualization Contest
Author: Alan Chalker
Creation Date: 4/7/09
Contents
Animation of result versus time improvements to score
Below is an animation showing how the leading entries stats evolved over the contest.
Load contest data
Load the contest data
load contest_data
score=[d.score];
timestamp=[d.timestamp];
result=[d.result];
cpu_time=[d.cpu_time];
passed=[d.passed];
charcount=[d.charCount];
Setup figure
Sets up the figure, axes, and text objects to sizes / positions good for the animation
figure('Position',[100 100 800 600],'Color','w'); td=subplot(4,3,[1 4 7 10]); set(gca,'Visible','off'); text(0,.2,{'Author:' 'Title:' 'Score:' 'Result:' 'CPU_time:' 'Length:'},'FontSize',10,'Interpreter','none'); text(.35,.35,'Current Leading Entry','FontSize',10); text(0,1,'Submission Time:','FontSize',10); text(0,.7,{'Author:' 'Title:' 'Score:' 'Result:' 'CPU_time:' 'Length:'},'FontSize',10,'Interpreter','none'); text(.35,.85,'Current Entry','FontSize',10); st=text(.2,.96,'','FontSize',10); ce=text(.4,.7,'','FontSize',10,'Interpreter','none'); le=text(.4,.2,'','FontSize',10,'Interpreter','none'); % Find all the leaders so we can setup the Y axis limits appropriately topscore=Inf; leaderind=1; for x=1:size(d,2) entry=d(x); if topscore>entry.score leaderind(end+1)=x; topscore=entry.score; end end % Ignore the first few leaders because they are outliers leaderind=leaderind(4:end); % Sets up the plots on the right side to graphically show the leader sc=subplot(4,3,[2 3]); set(gca,'Xtick',[],'XtickLabel',[],'YScale','log'); title('Score of Leading Entries'); axis(gca,[min(timestamp) max(timestamp) min(score(leaderind)) max(score(leaderind))]); hold on; ct=subplot(4,3,[5 6]); set(gca,'Xtick',[],'XtickLabel',[]); title('CPU Time of Leading Entries'); axis(gca,[min(timestamp) max(timestamp) min(cpu_time(leaderind)) max(cpu_time(leaderind))]); hold on; re=subplot(4,3,[8 9]); set(gca,'Xtick',[],'XtickLabel',[],'YScale','log'); title('Result of Leading Entries'); axis(gca,[min(timestamp) max(timestamp) min(result(leaderind)) max(result(leaderind))]); hold on; cc=subplot(4,3,[11 12]); set(gca,'Xtick',[],'XtickLabel',[]); title('Length of Leading Entries'); axis(gca,[min(timestamp) max(timestamp) min(charcount(leaderind)) max(charcount(leaderind))]); xlabel('Submission Time'); hold on;

Create frames
Show in sequence data for all the entries. To make the movie not too long only grab every 25th frame.
k=1; topscore=Inf; leaderind=1; for x=1:size(d,2) entry=d(x); subplot(td); set(ce,'String',{entry.author entry.title num2str(entry.score) num2str(entry.result) num2str(entry.cpu_time) num2str(entry.charCount)}); set(st,'String',datestr(entry.timestamp,0)); if topscore>entry.score set(le,'String',{entry.author entry.title num2str(entry.score) num2str(entry.result) num2str(entry.cpu_time) num2str(entry.charCount)}); topscore=entry.score; leaderind(end+1)=x; subplot(sc); plot(timestamp(leaderind),score(leaderind)); subplot(ct); plot(timestamp(leaderind),cpu_time(leaderind)); subplot(re); plot(timestamp(leaderind),result(leaderind)); subplot(cc); plot(timestamp(leaderind),charcount(leaderind)); end if rem(x,25)==0 drawnow; M(k)=getframe(gcf,[50 25 725 557]); k=k+1; end end

Create animated .gif file
Convert the movie to an .gif
[im,map] = rgb2ind(M(k-1).cdata,256,'nodither'); im(1,1,1,36) = 0; for x=1:k-1 im(:,:,1,x) = rgb2ind(M(x).cdata,map,'nodither'); end cd('html'); imwrite(im,map,'data.gif','DelayTime',0,'LoopCount',inf) cd('..');