Last active
August 29, 2015 14:14
-
-
Save alisonpope/93120e2ce816a22217e2 to your computer and use it in GitHub Desktop.
Data Visualisation Course Week 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** BRIEF | |
There appears to be a shift in the UK's political voting | |
preferences in recent years. The table below shows the | |
results of the BBC Poll of polls (average of the main opinion polls) | |
conducted in January 2015, 2014 and 2013. | |
Create a simple Processing sketch that shows this trend using | |
circles to represent each percentage, where each circle is | |
coloured according to the party it represents and sized | |
according to the percentage of people supporting that party. | |
**/ | |
// data variables | |
// hardcoded data for now | |
float con2015 = 32; | |
float con2014 = 31; | |
float con2013 = 31; | |
float lab2015 = 34; | |
float lab2014 = 39; | |
float lab2013 = 43; | |
float lib2015 = 7; | |
float lib2014 = 9; | |
float lib2013 = 10; | |
float oth2015 = 27; | |
float oth2014 = 21; | |
float oth2013 = 16; | |
void setup() | |
{ | |
size(400,200); | |
background(255); | |
} | |
void draw() | |
{ | |
// draw a version of this sketch | |
v1(); | |
} | |
void v1() | |
{ | |
// simple sketch that hard codes circle position, colour | |
// uses data variables for diameter. | |
noStroke(); | |
fill(10,28,139); | |
ellipse(100,25,con2013,con2013); | |
ellipse(200,25,con2014,con2014); | |
ellipse(300,25,con2015,con2015); | |
fill(255,0,0); | |
ellipse(100,75,lab2013,lab2013); | |
ellipse(200,75,lab2014,lab2014); | |
ellipse(300,75,lab2015,lab2015); | |
fill(234,220,52); | |
ellipse(100,125,lib2013,lib2013); | |
ellipse(200,125,lib2014,lib2014); | |
ellipse(300,125,lib2015,lib2015); | |
fill(203,203,199); | |
ellipse(100,175,oth2013,oth2013); | |
ellipse(200,175,oth2014,oth2014); | |
ellipse(300,175,oth2015,oth2015); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment