Code covered by the BSD License  

Highlights from
votebar

4.0

4.0 | 1 rating Rate this file 2 Downloads (last 30 days) File Size: 2.89 KB File ID: #27545
image thumbnail

votebar

by paul koch

 

09 May 2010

function to plot 'election-like' 3d bars

| Watch this File

File Information
Description

  function to plot election-like 3d bars.
  hp=votebar(high,val,colo,randomVote)

  INPUT:
  high: absolute height of the bars (1 value)
  val: a vector of N-values to plot
  colo: a 2D-matrix of N x RGB-color triplets
  randomVote: set [1] make your own election and compare with reality.
  This might be usefull to simulated the sort of randomness one sometimes
  feels after elections.

  OUTPUT: handles of the patches: for N-columns this is a 4 x N matrix,
   1st line: refering to the gray/empty urn(s)
   2nd -||-: -||- colored column(s)
   3rd -||-: -||- bottom of the colomn(s)
   4th -||-: -||- top of the column(s)
  
  
  % example 1: plot 10 columns as staircase , with random colors
   hp=votebar(7,1:7,[],0)
  
  %example 2; %participate in Germany's election, hit <space> to give your
  % vote
  val=rand(1,5)*100
  col=[0 0 0;1 0 0; 1 1 0;0 .6 0; 1 0 1];
  votebar(100,val,col,1);

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
11 May 2010 Wolfgang Schwanghart

Nice one! Works perfectly. Yet I think this function could be made more user-friendly in some ways.

1. Leave the latter two inputs optional such that the function can be called like hp=votebar(high,val);
2. Surpress the output of hp if the function is called without output arguments

Moreover, I found it extremely useful to add some functionality to label the plots. For example it might be great, if a legend could be added to the figure using the function legend.

Yet, all in all this function offers a nice add-on to Matlab's visualization functionality.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
bar paul koch 10 May 2010 13:12:44
bar3 paul koch 10 May 2010 13:12:44
plot paul koch 10 May 2010 13:12:44

Contact us at files@mathworks.com