File:Canadian federal general elections.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 1,207 × 507 pixels, file size: 68 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description
English: Percentage of popular vote in Canadian federal general elections from 1867 to 2011.

Data source: http://www.parl.gc.ca/parlinfo/compilations/electionsandridings/ResultsParty.aspx

Color code: https://en.wikipedia.org/wiki/Template:Canadian_politics/party_colours
Date
Source Own work
 
This W3C-unspecified plot was created with Matplotlib.
Author Fjalnes

Source code[edit]

Source Code in python:
# coding=utf-8
import pylab as pl
import matplotlib
matplotlib.rcParams['svg.fonttype'] = 'none'
import numpy as np
pl.ion()


#color codes as in http://en.wikipedia.org/wiki/Template:Canadian_politics/party_colours, but more saturated to enhance visibility
colorcodes = {'Liberal Party of Canada': '#ff7171',
              'Conservative Party of Canada':'#5290ff',
              'Progressive Conservative Party':'#9999FF',
              'Conservative (1867-1942)':'#9999FF',
              'Canadian Reform Conservative Alliance':'#5F9EA0',
              'Reform Party':'#3CB371',
              'New Democratic Party':'#ffa355',
              'Co-operative Commonwealth Federation':'#ffff00',
              'Bloc Québécois':'#82cfff',
              'Social Credit Party':'#7fff7f',
              'Ralliement des créditistes':'#7fff7f',
              'Other':'#000000',
              'Green Party of Canada':'#2F873E',
              'New Democracy (Includes votes for the Social Credit)':'#7fff7f',
              'Liberal Labour Party*':'#FFFFFF',
              'Unionist Party':'#9999FF'}

#Results of elections
#data source: http://www.parl.gc.ca/parlinfo/compilations/electionsandridings/ResultsParty.aspx
#the following dictionary contains for each party a list of years and four lists of the corresponding results.
#results[party] = [years, [Elected_Members,	Number_of_Candidates, Number_of_Valid_Votes, Percentage_of_Popular_Vote]]
results = \
{'Ralliement des cr\xc3\xa9ditistes': [[1968, 1965], [[14, 71, 361045, 4.4], [9, 77, 359438, 4.7]]], \
'Conservative (1867-1942)': [[1935, 1930, 1926, 1925, 1921, 1917, 1911, 1908, 1904, 1900, 1896, 1891, 1887, 1882, 1878, 1874, 1872, 1867], [[39, 232, 1311459, 29.8], [137, 233, 1909955, 49.0], [91, 233, 1504855, 46.2], [116, 234, 1466324, 46.6], [50, 208, 945681, 30.3], [153, 0, 1074918, 57.0], [133, 215, 669594, 51.2], [85, 212, 552134, 47.0], [75, 205, 483177, 46.9], [81, 204, 450790, 47.4], [88, 209, 416640, 46.3], [123, 217, 404599, 52.0], [123, 209, 367191, 50.7], [139, 0, 275537, 53.38], [137, 0, 282966, 53.2], [73, 0, 0, 45.4], [103, 0, 0, 49.9], [101, 0, 0, 50.0]]], \
'Reform Party': [[1997, 1993], [[60, 227, 2513070, 19.4], [52, 207, 2559245, 18.7]]], \
'New Democratic Party': [[2011, 2008, 2006, 2004, 2000, 1997, 1993, 1988, 1984, 1980, 1979, 1974, 1972, 1968, 1965, 1963, 1962], [[103, 308, 4512411, 30.6], [37, 308, 2515288, 18.2], [29, 308, 2589597, 17.5], [19, 308, 2127403, 15.7], [13, 298, 1093868, 8.5], [21, 301, 1434509, 11.0], [9, 294, 939575, 6.9], [43, 295, 2685308, 20.38], [30, 282, 2359915, 18.8], [32, 282, 2164987, 19.78], [26, 282, 2048779, 17.88], [16, 262, 1467748, 15.44], [31, 251, 1713528, 17.72], [22, 263, 1378260, 17.0], [21, 255, 1381658, 17.9], [17, 232, 1037857, 13.1], [19, 218, 1036853, 13.4]]], \
'Canadian Reform Conservative Alliance': [[2000], [[66, 298, 3276929, 25.5]]], \
'New Democracy (Includes votes for the Social Credit)': [[1940], [[10, 30, 123443, 2.7]]], \
'Progressive Conservative Party': [[2000, 1997, 1993, 1988, 1984, 1980, 1979, 1974, 1972, 1968, 1965, 1963, 1962, 1958, 1957, 1953, 1949, 1945, 1940], [[12, 291, 1566998, 12.2], [20, 301, 2446705, 18.8], [2, 295, 2186422, 16.0], [169, 295, 5667563, 43.02], [211, 282, 6278697, 50.03], [103, 282, 3552994, 32.45], [136, 282, 4111559, 35.89], [95, 264, 3369335, 35.44], [107, 264, 3383530, 35.0], [72, 263, 2554880, 31.4], [97, 265, 2499913, 32.4], [95, 265, 2591614, 32.9], [116, 265, 2868295, 37.3], [208, 265, 3910852, 53.7], [112, 256, 2578045, 39.0], [51, 248, 1751215, 31.0], [41, 250, 1742276, 29.7], [67, 203, 1455453, 27.7], [39, 213, 1416257, 30.6]]], \
'Liberal Labour Party*': [[1958], [[1, 1, 11956, 0.2]]], \
'Other': [[2011, 2008, 2006, 2004, 2000, 1997, 1993, 1988, 1984, 1980, 1979, 1974, 1972, 1968, 1965, 1963, 1962, 1958, 1957, 1953, 1949, 1945, 1940, 1935, 1930, 1926, 1925, 1921, 1917, 1911, 1908, 1904, 1900, 1896, 1891, 1887, 1882, 1878, 1874, 1872, 1867], [[0, 285, 129703, 1.0], [2, 604, 1096761, 7.8], [1, 635, 820875, 5.5], [1, 686, 755472, 5.6], [0, 545, 290220, 2.3], [1, 467, 211482, 1.6], [1, 989, 488453, 3.6], [0, 681, 719841, 4.65], [1, 552, 376964, 3.0], [0, 574, 190533, 1.74], [0, 475, 173441, 1.52], [1, 267, 84818, 0.9], [2, 173, 362773, 1.19], [1, 76, 71910, 0.9], [2, 63, 90334, 1.1], [0, 38, 30112, 0.4], [1, 40, 14336, 0.2], [0, 50, 35630, 0.4], [4, 66, 87188, 1.3], [5, 143, 127961, 2.3], [8, 132, 255079, 4.4], [12, 216, 582393, 11.1], [10, 85, 151116, 3.3], [11, 251, 566041, 12.8], [17, 79, 274180, 7.1], [38, 77, 329849, 10.2], [30, 130, 408612, 13.0], [69, 225, 905562, 29.0], [0, 0, 55325, 2.9], [2, 26, 12831, 1.0], [3, 31, 28299, 2.4], [0, 28, 6784, 0.7], [0, 25, 5546, 0.6], [7, 61, 76900, 8.6], [0, 27, 12662, 1.6], [0, 37, 2708, 0.4], [0, 0, 187, 0.04], [0, 0, 8817, 1.7], [0, 0, 0, 0.8], [0, 0, 0, 1.0], [0, 0, 0, 1.0]]], \
'Bloc Qu\xc3\xa9b\xc3\xa9cois': [[2011, 2008, 2006, 2004, 2000, 1997, 1993], [[4, 75, 891425, 6.1], [49, 75, 1379991, 10.0], [51, 75, 1553201, 10.5], [54, 75, 1680109, 12.4], [38, 75, 1377727, 10.7], [44, 75, 1385821, 10.7], [54, 75, 1846024, 13.5]]], \
'Liberal Party of Canada': [[2011, 2008, 2006, 2004, 2000, 1997, 1993, 1988, 1984, 1980, 1979, 1974, 1972, 1968, 1965, 1963, 1962, 1958, 1957, 1953, 1949, 1945, 1940, 1935, 1930, 1926, 1925, 1921, 1917, 1911, 1908, 1904, 1900, 1896, 1891, 1887, 1882, 1878, 1874, 1872, 1867], [[34, 308, 2783076, 18.9], [77, 307, 3633185, 26.3], [103, 308, 4479415, 30.2], [135, 308, 4982220, 36.7], [172, 301, 5252031, 40.8], [155, 301, 4994377, 38.5], [177, 295, 5647952, 41.3], [83, 294, 4205072, 31.92], [40, 282, 3516486, 28.03], [147, 282, 4853914, 44.34], [114, 282, 4594319, 40.1], [141, 264, 4102776, 43.16], [109, 263, 3718258, 38.46], [155, 263, 3696945, 45.5], [131, 265, 3099519, 40.2], [129, 264, 3293790, 41.7], [99, 263, 2874076, 37.4], [48, 264, 2447744, 33.6], [105, 264, 2796039, 42.3], [171, 264, 2819813, 50.0], [190, 258, 2929391, 50.1], [125, 233, 2170625, 41.4], [178, 244, 2536214, 54.9], [171, 244, 1955727, 44.4], [91, 234, 1714860, 43.9], [116, 220, 1421804, 43.6], [99, 215, 1269401, 40.4], [116, 202, 1272660, 40.7], [82, 0, 755086, 40.1], [86, 222, 625103, 47.8], [133, 216, 594270, 50.6], [139, 211, 540827, 52.5], [132, 207, 494427, 52.0], [118, 193, 405506, 45.1], [92, 192, 361238, 46.4], [92, 193, 353919, 48.9], [71, 0, 240420, 46.58], [69, 0, 240065, 45.1], [133, 0, 0, 53.8], [97, 0, 0, 49.1], [80, 0, 0, 49.0]]], \
'Social Credit Party': [[1988, 1984, 1980, 1979, 1974, 1972, 1968, 1965, 1963, 1962, 1958, 1957, 1953, 1949, 1945, 1935], [[0, 9, 3407, 0.03], [0, 51, 16659, 0.13], [0, 84, 185486, 1.69], [6, 103, 527604, 4.61], [11, 152, 481231, 5.06], [15, 166, 737972, 7.63], [0, 31, 62956, 0.8], [5, 86, 282454, 3.7], [24, 224, 940703, 11.9], [30, 230, 896574, 11.7], [0, 82, 188717, 2.6], [19, 114, 437049, 6.6], [15, 72, 305973, 5.4], [10, 28, 139815, 2.4], [13, 95, 214998, 4.1], [17, 46, 182767, 4.1]]], \
'Total': [[2011, 2008, 2006, 2004, 2000, 1997, 1993, 1988, 1984, 1980, 1979, 1974, 1972, 1968, 1965, 1963, 1962, 1958, 1957, 1953, 1949, 1945, 1940, 1935, 1930, 1926, 1925, 1921, 1917, 1911, 1908, 1904, 1900, 1896, 1891, 1887, 1882, 1878, 1874, 1872, 1867], [[308, 1587, 14723980, 100.0], [308, 1601, 13834294, 100.0], [308, 1634, 14817159, 100.0], [308, 1685, 13564702, 100.0], [301, 1808, 12857773, 100.0], [301, 1672, 12985964, 100.0], [295, 2155, 13667671, 100.0], [295, 1574, 13281191, 100.0], [282, 1449, 12548721, 100.0], [282, 1504, 10947914, 100.0], [282, 1424, 11455702, 100.0], [264, 1209, 9505908, 100.0], [264, 1117, 9916061, 100.0], [264, 967, 8125996, 100.0], [265, 1011, 7713316, 100.0], [265, 1023, 7894076, 100.0], [265, 1016, 7690134, 100.0], [265, 831, 7287297, 100.0], [265, 862, 6605980, 100.0], [265, 897, 5641272, 100.0], [262, 848, 5848971, 100.0], [245, 952, 5246130, 100.0], [245, 668, 4620260, 100.0], [245, 892, 4406854, 100.0], [245, 546, 3898995, 100.0], [245, 530, 3256508, 100.0], [245, 579, 3144337, 100.0], [235, 635, 3123903, 100.0], [235, 470, 1885329, 100.0], [221, 463, 1307528, 100.0], [221, 459, 1174703, 100.0], [214, 444, 1030788, 100.1], [213, 436, 950763, 100.0], [213, 463, 899046, 100.0], [215, 436, 778499, 100.0], [215, 439, 723818, 100.0], [210, 413, 516144, 100.0], [206, 412, 531848, 100.0], [206, 364, 0, 100.0], [200, 337, 0, 100.0], [181, 0, 0, 100.0]]], \
'Conservative Party of Canada': [[2011, 2008, 2006, 2004], [[166, 307, 5835270, 39.6], [143, 307, 5209069, 37.7], [124, 308, 5374071, 36.3], [99, 308, 4019498, 29.6]]], \
'Co-operative Commonwealth Federation': [[1958, 1957, 1953, 1949, 1945, 1940, 1935], [[8, 169, 692398, 9.5], [25, 162, 707659, 10.8], [23, 170, 636310, 11.3], [13, 180, 782410, 13.4], [28, 205, 822661, 15.7], [8, 96, 393230, 8.5], [7, 119, 390860, 8.9]]], \
'Green Party of Canada': [[2011], [[1, 304, 572095, 3.9]]]}

#years of elections
years = [2014,2011, 2008, 2006, 2004, 2000, 1997, 1993, 1988, 1984, 1980, 1979, 1974, 1972, 1968, 1965, 1963, 1962, 1958, 1957, 1953, 1949, 1945, 1940, 1935, 1930, 1926, 1925, 1921, 1917, 1911, 1908, 1904, 1900, 1896, 1891, 1887, 1882, 1878, 1874, 1872, 1867]

#governments after the elections
#source https://de.wikipedia.org/wiki/Liste_der_kanadischen_Unterhauswahlen
governments = ['Conservative Party of Canada', 'Conservative Party of Canada', 'Conservative Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Progressive Conservative Party', 'Progressive Conservative Party', 'Liberal Party of Canada', 'Progressive Conservative Party', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Progressive Conservative Party', 'Progressive Conservative Party', 'Progressive Conservative Party', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Conservative (1867-1942)', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Unionist Party', 'Conservative (1867-1942)', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Liberal Party of Canada', 'Conservative (1867-1942)', 'Conservative (1867-1942)', 'Conservative (1867-1942)', 'Conservative (1867-1942)', 'Liberal Party of Canada', 'Conservative (1867-1942)', 'Conservative (1867-1942)']


#add some small parties to 'Others'
def add_to_others(party):
    for i,year in enumerate(results[party][0]):
        j = results['Other'][0].index(year)
        results['Other'][1][j] = [a+b for a,b in zip(results['Other'][1][j],results[party][1][i])]
    del results[party]
add_to_others('Reform Party')
add_to_others('Liberal Labour Party*')
add_to_others('New Democracy (Includes votes for the Social Credit)')
add_to_others('Green Party of Canada')
add_to_others('Canadian Reform Conservative Alliance')
add_to_others('Ralliement des créditistes')

#plot it
fig = pl.figure(figsize=(15.96,6.125))
for party in ['Conservative (1867-1942)', 'Progressive Conservative Party', 'Conservative Party of Canada', 'Liberal Party of Canada','New Democratic Party', 'Bloc Qu\xc3\xa9b\xc3\xa9cois', 'Social Credit Party', 'Co-operative Commonwealth Federation', 'Other']:
    result = results[party]
    pl.plot(result[0],[r[3] for r in result[1]],color=colorcodes[party],linewidth=3,label=unicode(party,encoding='utf8'))
pl.xticks([years[i] for i in range(len(years)) if i%3==0 or i==len(years)-1])
pl.xlim(min(years),max(years))
pl.ylim(0,60)
pl.yticks(pl.yticks()[0],[str(int(p))+'%' for p in pl.yticks()[0]])
ax = pl.gca()
for i in xrange(len(governments)):
    ax.add_patch(pl.Rectangle((years[i],0),years[i+1]-years[i],60,color=colorcodes[governments[i]],alpha=0.35))
pl.show()
pl.legend(fontsize=12,loc='center left')

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current06:46, 25 February 2014Thumbnail for version as of 06:46, 25 February 20141,207 × 507 (68 KB)Imalipusram (talk | contribs)yellow is now yellow
18:24, 19 February 2014Thumbnail for version as of 18:24, 19 February 20141,207 × 507 (65 KB)Fjalnes (talk | contribs)Increased saturation.
14:29, 17 February 2014Thumbnail for version as of 14:29, 17 February 20141,207 × 507 (65 KB)Fjalnes (talk | contribs)SVG problem fixed. This version should be rendered correctly.
17:18, 14 February 2014Thumbnail for version as of 17:18, 14 February 20141,207 × 507 (73 KB)Fjalnes (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

File usage on other wikis

Metadata