File Exchange Pick of the Week

Our best user submissions

Votebar

Sean's pick this week is votebar by paul koch.

Paul's votebar is a nice utility for viewing cylindrical three dimensional bar plots like you would see after an election. For example:

n = 4;
pct = randfixedsum(n,1,100,0,100); % File Exchange
votebar(100, pct, parula(n), 0);

Or in the case of the "Is my wife right?" CODY problem:

votebar(100,[100 0],[0 1 0; 0 0 1],0);
text(1.5,-1,'Yes','FontSize',20)
text(1.5,1.5,'No','FontSize',20)
title('Is My Wife Right?')

Let's take a look at this with the election data from the 2014 Massachusetts gubernatorial race.

% Data and setup
votes = [1041640 1001279 71144 19192 16125];
pct = votes./sum(votes)*100;
names = {'Charlie Baker', 'Martha Coakley', 'Evan Falchuk', 'Scott Lively', 'Jeff McCormick'};
colors = [1 0 0; 0 0 1; 0.541 0.706 0.486]; % RGBcolors
idx = [1 2 3 3 3].'; % Index into colors

% Votebar
hp = votebar(100, pct, colors(idx,:), 0);

% Decorating
legend(hp(3,:),names)
lighting gouraud
material shiny
title('Massachusetts Gubernatorial Results')
view(84,14)
text(-6.5,-2,'%','FontSize',20)

Source: http://www.politico.com/2014-election/results/map/governor/massachusetts/#.VGIlaE1OXcw

Comments

Give it a try and let us know what you think here or leave a comment for Paul.




Published with MATLAB® R2014b

|

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.