I'm trying to use Mathematica to create some visual representations of the votes cast in the recent Mathematica-StackExchange moderator elections. (Not the vote-counting system itself, OpenSTV, but rather the choices people made.) This is what I've got so far, but I'm stuck on how to represent the data visually, not knowing much about charting.

According to this Meta post, the results can be downloaded in text form from this page. It looks to be a plain text file (with oddball Unicode characters):

Although I couldn't find a guide to the format, it looks reasonable to assume that the initial {6,3} is the number of candidates and the number of vacancies, that the strings at the end before the election name are the candidates names, and that the lists starting with 1 and ending with 0 are the individual votes. So:

votes = Cases[data, {1, a_, b_, c_, 0} -> {a, b, c}]

gives the votes:

(*
{{1, 2, 3}, {2, 4, 3}, ... {1, 3, 5}}
*)

which I suppose can be turned into something more readable by picking up the names from the end of the list:

5 Answers
5

If we assume that the votes are listed in the order they were cast, we can look at how the race evolved over time during the election period and monitor step by step who were in the leading positions. In this case I'm just calculating the number of votes without taking into account the rank.

Love it. One day all elections will be like this, only live!
–
cormullionSep 27 '12 at 16:18

@cormullion In this case, I propose "spermatozoon race plot" as the name for this plot and hope that Microsoft doesn't try to patent it like Tufte's sparklines.
–
VLCSep 27 '12 at 16:43

Haha, very nice! But I don't think it is in order, because then there would be a 1:1 correspondence with when the Constituent badges were awarded, leading to a loss in anonymity of votes. Also, votes can be changed anytime during the 7 days, further complicating it. Nevertheless, you get a +1 for a very interesting idea! :)
–
The Toad♦Sep 27 '12 at 17:16

Hover over a bubble for a tooltip showing the 3 choices and the number of people who voted that way.

Another one

Here each voter is a vertex in a graph, with 7 larger vertices for the candidates. Each vote is a directed edge from voter to candidate (there is no distinction between first, second and third choices). By using "SpringEmbedding" the graph layout algorithm positions the candidates closer together if a lot of voters selected them both. This therefore reveals similar information to Sjoerd's graph.

You can see for example a clear separation between Verbeia and the {Wizard, RM, JM} cluster. This comes from her popularity with the less conventional voters (those who also voted for the less popular candidates).

And Another One

I wanted to look at the preference aspect of the votes. For example if someone votes {Fx, JM, Wz} it implies that they consider Fx better than all the other candidates, JM better than all the candidates except Fx, and so on. We can draw up a table showing the number of voters expressing a preference for candidate A over candidate B:

Another interesting way of looking at the voting data would be to visualize the 2nd and 3rd choices for a given 1st choice. In a way, this is a breakdown of Sjoerd's plot when a given candidate is the 1st choice.

For example, among those who voted for me as the 1st choice, they were evenly split between J. M., Mr.Wizard and Verbeia for 2nd choice and a similar even split between the three for third, with Verbeia having a slight edge.

On the other hand, those who voted for Mr.Wizard as the 1st choice strongly preferred me as the second choice and Verbeia as the third:

Similar charts for J. M. (left) and Verbeia (right) are below:

It appears to me as if the voting patterns roughly fell into two camps — one which felt there should be 2 of the old and one of the new, and the other, which felt there should be two of the new and one of the old. Both of these are very reasonable voting behaviours and it doesn't spring any surprises.

BLT file format

The format for the .blt file is fairly simple.

The first number on the first line is the number of candidates and the second number is the number of seats.

If any candidates have withdrawn, their IDs (see point 4) will be listed in the second line with a - sign prepended (like -6, for example). If no candidates have withdrawn, this line is not included.

The votes follow next. These have the general pattern of

count, 1st choice, 2nd choice, 3rd choice, 0

In this case, the individual votes were given, but it is not uncommon to see a tallied count of unique triplets. 0 terminates each line.

The next 7 lines (in general, the number of candidates + 1) are the identifiers for the candidate IDs. 0 indicates no vote cast for that choice.

The final line in the file is the title of the election.

Code for the above charts

I have made the structure apparent in the formatting below to aid the eye. I've also "fixed" my name so that it doesn't throw any oddball unicode characters :)

You then call it as visualizeVotes[4], for Mr.Wizard. The IDs can be found in $names. There is some small glitch in the function for ID 6 (Eiyrioü von Kauyf), probably because of the lack of votes, but I'm not going to fix it.

With small tables of values, complex graphics can obscure the data. Ed Tufte has recommended just showing the counts. He also points out the worth of presenting the values in a meaningful order: here, the rows go from first to third place while the columns are (roughly) in order of the standings.

This illuminates why each person placed as they did: there were clear choices for first, second, and third places along with a strong fourth candidate.

Those interested in exploring connections within the voting will also appreciate the graphical display of Sjoerd C. de Vries (which shows bivariate associations) and might also want to look into ways of visualizing the hypergraph of votes (where the candidates form vertices which are connected in triples by weighted 2-simplices indicating how many times all three candidates were chosen simultaneously by a voter).

I like the second one very much. It's telling a story using numbers and colours. Did you just guess at order?
–
cormullionSep 27 '12 at 11:35

@cor The order could be justified as a sort on total votes (with non-votes placed last), but the fact is that while fiddling with the graphical details, I adjusted an initial ordering to emphasize the diagonal 32-26-23 pattern.
–
whuberSep 27 '12 at 13:04

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.