Skip to content

Instantly share code, notes, and snippets.

@borgar
Last active January 1, 2020 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save borgar/193316526756abc2b07c6f866e865519 to your computer and use it in GitHub Desktop.
Save borgar/193316526756abc2b07c6f866e865519 to your computer and use it in GitHub Desktop.
A single constituency
license: mit
height: 500

One thing Icelanders commonly cite off their laundry list of solutions to "fixing parliament" is to make the whole of Iceland a single constituency.

When questioned though, few people seem to have a firm grasp of how of the current electoral system works. This in itself may be a red-flag as representational systems of government are built on trust and one can only trust a system as far as one understands it.

The question is, what exactly would this change solve? The idea is that disparity of population in the current constituencies introduces an unfair bias. One way to solve this is to move seats between constituencies, and in fact the Icelandic Constitution addresses this to some extent. Another way would be to abolish partioning altogeather.

This chart explores what would have happened to the four major parties in past elections if there were only a single constituency. The coloured bars represent the number of seats each party got and the grey bars represent allotted seats had the country been a single constituency.

This ignores all indications that the number and size of constituencies may affect the number and size of the parties the live in it.

It is noteworthy here that, historically, the Progressive Party (Framsóknarflokkur) has the most obvious bias. Their strongest constituency by far is North-East, which has the lowest voters-per-seat. This may go some way to explain the phenomenon explored in Predictions vs. Elections.

party year percent seats
Alþýðubandalag 1963 16.0 9
Alþýðubandalag 1967 17.6 10
Alþýðubandalag 1971 17.1 10
Alþýðubandalag 1974 18.3 11
Alþýðubandalag 1978 22.9 14
Alþýðubandalag 1979 19.7 11
Alþýðubandalag 1983 17.3 10
Alþýðubandalag 1987 13.3 8
Alþýðubandalag 1991 14.4 9
Alþýðubandalag 1995 14.3 9
Alþýðuflokkur 1963 14.2 8
Alþýðuflokkur 1967 15.7 9
Alþýðuflokkur 1971 10.5 6
Alþýðuflokkur 1974 9.1 5
Alþýðuflokkur 1978 22.0 14
Alþýðuflokkur 1979 17.4 10
Alþýðuflokkur 1983 11.7 6
Alþýðuflokkur 1987 15.2 10
Alþýðuflokkur 1991 15.5 10
Alþýðuflokkur 1995 11.4 7
Alþýðufylkingin 2013 0.1 0
Alþýðufylkingin 2016 0.3 0
Anarkistar á Íslandi 1999 0.1 0
Aðrir og utan flokka 1983 0.5 0
Aðrir og utan flokka 1987 2.87 0
Aðrir og utan flokka 1995 1.1 0
Aðrir og utan flokka 1999 0.4 0
Bandalag jafnaðarmanna 1983 7.3 4
Bandalag jafnaðarmanna 1987 0.2 0
Björt framtíð 2013 8.2 6
Björt framtíð 2016 7.2 4
Borgaraflokkur 1987 10.9 7
Borgarahreyfingin 2009 7.2 4
Dögun 2013 3.1 0
Dögun 2016 1.7 0
Flokkur Fólksins 2016 3.5 0
Flokkur heimilanna 2013 3.0 0
Flokkur mannsins 1987 1.5 0
Framboðsflokkurinn 1971 2.0 0
Framsóknarflokkur 1963 28.2 19
Framsóknarflokkur 1967 28.1 18
Framsóknarflokkur 1971 25.3 17
Framsóknarflokkur 1974 24.9 17
Framsóknarflokkur 1978 16.9 12
Framsóknarflokkur 1979 24.9 17
Framsóknarflokkur 1983 19.0 14
Framsóknarflokkur 1987 18.9 13
Framsóknarflokkur 1991 18.9 13
Framsóknarflokkur 1995 23.3 15
Framsóknarflokkur 1999 18.4 12
Framsóknarflokkur 2003 17.7 12
Framsóknarflokkur 2007 11.7 7
Framsóknarflokkur 2009 14.8 9
Framsóknarflokkur 2013 24.4 19
Framsóknarflokkur 2016 11.5 8
Frjálslyndi flokkurinn 1999 4.2 2
Frjálslyndi flokkurinn 2003 7.4 4
Frjálslyndi flokkurinn 2007 7.3 4
Frjálslyndi flokkurinn 2009 2.2
Frjálslyndir 1991 0.6 0
Fylking baráttusinnaðra kommúnista 1978 0.2 0
Fylking baráttusinnaðra kommúnista 1979 0.4 1
Fylkingin - baráttusamtök sósíalista 1974 0.2 0
Grænt framboð 1991 0.1 0
Heimastjórnarsamtökin 1991 0.3 0
Hinn flokkurinn 1979 0.2 1
Hægri grænir 2013 1.7 0
Húmanistaflokkurinn 1999 0.4 0
Húmanistaflokkurinn 2013 0.1 0
Húmanistaflokkurinn 2016 0.0 0
Kommúnistaflokkur Íslands (m-l) 1974 0.1 0
Kommúnistaflokkur Íslands (m-l) 1978 0.1 0
Kristileg stjórnmálasamtök 1995 0.2 0
Landsbyggðarflokkurinn 2013 0.2 0
Lýðræðisflokkurinn 1974 0.1 0
Lýðræðishreyfingin 2009 0.6 0
Lýðræðisvaktin 2013 2.5 0
Náttúrulagaflokkurinn 1995 0.6 0
Nýtt afl 2003 1.0 0
Píratar 2013 5.1 3
Píratar 2016 14.5 10
Regnboginn 2013 1.1 0
Samfylkingin 1999 26.8 17
Samfylkingin 2003 31.0 20
Samfylkingin 2007 26.8 18
Samfylkingin 2009 29.8 20
Samfylkingin 2013 12.9 9
Samfylkingin 2016 5.7 3
Samtök frjálslyndra og vinstri manna 1971 8.9 5
Samtök frjálslyndra og vinstri manna 1974 4.6 2
Samtök frjálslyndra og vinstrimanna 1978 3.3 0
Samtök um jafnrétti og félagshyggju 1987 1.2 1
Samtök um kvennalista 1983 5.5 3
Samtök um kvennalista 1987 10.1 6
Samtök um kvennalista 1991 8.3 5
Samtök um kvennalista 1995 4.9 3
Samtök öfgasinnaðra jafnaðarmanna 1991 0.1 0
Sjálfstæðisflokkur 1963 41.4 24
Sjálfstæðisflokkur 1967 37.5 23
Sjálfstæðisflokkur 1971 36.2 22
Sjálfstæðisflokkur 1974 42.7 25
Sjálfstæðisflokkur 1978 32.7 20
Sjálfstæðisflokkur 1979 35.4 21
Sjálfstæðisflokkur 1983 38.7 23
Sjálfstæðisflokkur 1987 27.2 18
Sjálfstæðisflokkur 1991 38.6 26
Sjálfstæðisflokkur 1995 37.1 25
Sjálfstæðisflokkur 1999 40.7 26
Sjálfstæðisflokkur 2003 33.7 22
Sjálfstæðisflokkur 2007 36.6 25
Sjálfstæðisflokkur 2009 23.7 16
Sjálfstæðisflokkur 2013 26.7 19
Sjálfstæðisflokkur 2016 29.0 21
Stjórnmálaflokkurinn 1978 0.4 0
Sturla Jónsson 2013 0.1 0
Sólskinsflokkurinn 1979 0.1 1
Verkamannaflokkur Íslands 1991 0.01 0
Vinstrihreyfingin - grænt framboð 1999 9.1 6
Vinstrihreyfingin - grænt framboð 2003 8.8 5
Vinstrihreyfingin - grænt framboð 2007 14.3 9
Vinstrihreyfingin - grænt framboð 2009 21.7 14
Vinstrihreyfingin - grænt framboð 2013 10.9 7
Vinstrihreyfingin - grænt framboð 2016 15.9 10
Viðreisn 2016 10.5 7
Íslandshreyfingin 2007 3.3 0
Íslenska þjóðfylkingin 2016 0.2 0
Óháð framboð á Norðurlandi eystra 1979 0.7 1
Óháð framboð á Suðurlandi 1979 1.2 1
Óháð framboð í Austurlandskjörd. 1963 0.2 0
Óháði lýðræðisflokkurinn 1967 1.1 0
Óháðir á Suðurlandi 1978 0.4 0
Óháðir á Vestfjörðum 1978 0.6 0
Óháðir í Reykjaneskjördæmi 1978 0.5 0
Óháðir í Suðurkjördæmi 2003 0.5 0
Þjóðarflokkurinn - Flokkur mannsins 1991 1.8 0
Þjóðarflokkurinn 1987 1.4 0
Þjóðvaki, hreyfing fólksins 1995 7.2 4
<!DOCTYPE html>
<meta charset="utf-8">
<style>
text {
font: 12px sans-serif;
fill: #555;
}
text.title {
font-size: 14px;
}
.calc,
.real {
stroke: white;
stroke-width: .75;
}
.calc {
fill: #ccc;
}
.axis-y line {
stroke: #888;
stroke-dasharray: 2 2;
}
.axis-y .zero {
stroke-dasharray: none;
}
.axis-y path,
.axis-x path {
display: none;
}
</style>
<body>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var margin = {top: 40, right: 10, bottom: 30, left: 40},
width = 470 - margin.left - margin.right,
height = 250 - margin.top - margin.bottom;
var x = d3.scaleBand().rangeRound([0, width]).padding(0.2),
y = d3.scaleLinear().range([height, 0]);
var palette = {
'Sjálfstæðisflokkur': '#5DA5DA',
'Framsóknarflokkur': '#B276B2',
'Alþýðubandalag': '#B2912F',
'Vinstrihreyfingin - grænt framboð': '#60BD68',
'Alþýðuflokkur': "#F17CB0",
'Samfylkingin': "#F15854",
};
var dhont = ( parties, total_seats ) => {
var quot = d => d.percent / ( d._seats + 1 );
parties.forEach(d => { d._seats = 0; });
for (var round=0; round<total_seats; round++) {
var top = parties.sort((a, b) => quot(b) - quot(a))[0];
top._seats++;
}
};
var y2d = ( d ) => {
var y = d % 100;
return y < 10 ? `'0${y}` : `'${y}`;
};
var rowParse = d => {
d.year = +d.year;
d.percent = (+d.percent)/100;
d.seats = +d.seats;
return d;
};
var num_mps = {
1963: 60, 1967: 60, 1971: 60, 1974: 60,
1978: 60, 1979: 60, 1983: 60, 1987: 63,
1991: 63, 1995: 63, 1999: 63, 2003: 63,
2007: 63, 2009: 63, 2013: 63, 2016: 63,
};
d3.csv('elections.csv', rowParse, data => {
y.domain([0, 26]);
x.domain(data.map(d => d.year).sort(d3.ascending));
// calculate seats as if there was 1 constituency
x.domain().forEach(year => {
dhont(data.filter(d => d.year === year), num_mps[year]);
});
plot(['Sjálfstæðisflokkur'], data);
plot(['Framsóknarflokkur'], data);
plot(['Alþýðuflokkur', 'Samfylkingin'], data);
plot(['Alþýðubandalag', 'Vinstrihreyfingin - grænt framboð'], data);
});
function plot (parties, data, polls) {
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", `translate(${margin.left},${margin.top})`);
// axis
svg.append("g")
.attr("class", "axis axis-x")
.attr("transform", `translate(0,${height})`)
.call(d3.axisBottom(x).tickSize(3).tickFormat(y2d));
svg.append("g")
.attr("class", "axis axis-y")
.call(d3.axisLeft(y).tickSize(-width).ticks(5))
.selectAll('line')
.attr('class', d => d ? '' : 'zero');
// title
svg.append("text")
.attr("class", "title")
.attr("x", width/2)
.attr("y", -18)
.attr("dy", ".32em")
.attr("text-anchor", "middle")
.text(parties.join(' → '));
// split to seats
var dt = [], oc = [];
data
.filter(d => parties.indexOf(d.party) !== -1)
.forEach(d => {
for (var i = 0; i < d.seats; i++) {
dt.push({
party: d.party,
seat: i + 1,
year: d.year,
seats: d.seats,
percent: d.percent,
});
}
for (var i = 0; i < d._seats; i++) {
oc.push({
party: d.party,
seat: i + 1,
year: d.year,
seats: d.seats,
percent: d.percent,
});
}
});
var w = x.bandwidth() / 2;
svg.selectAll(".real")
.data(dt).enter()
.append("rect")
.attr("class", "real")
.attr("x", d => x(d.year))
.attr("y", d => y(d.seat) - 0.5)
.attr("width", w)
.attr("height", d => y(d.seat) - y(d.seat+1))
.attr("fill", d => palette[d.party]);
// if there was only 1 constituency
svg.selectAll(".calc")
.data(oc).enter()
.append("rect")
.attr("class", "calc")
.attr("x", d => x(d.year) + w)
.attr("y", d => y(d.seat) - 0.5)
.attr("width", w)
.attr("height", d => y(d.seat) - y(d.seat+1));
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment