Need help with ggparliament?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

RobWHickman
131 Stars 12 Forks Other 352 Commits 5 Opened issues

Description

Simple parliament plots using ggplot2

Services available

!
?

Need anything else?

Contributors list

# 379,018
TeX
R
ggplot2
r-packa...
215 commits
# 233,926
R
ggplot2
r-packa...
HTML
88 commits
# 65,572
R
aws-s3
excel
stata
10 commits
# 382,802
Shell
uber
C
hexagon
4 commits

title: "README" output: github_document

pagetitle: README

Status

Build Status CRAN Status Downloads DOI

ggparliament
: Parliament plots

This package attempts to implement "parliament plots" - visual representations of the composition of legislatures that display seats colour-coded by party. The input is a data frame containing one row per party, with columns representing party name/label and number of seats, respectively.

This

R
package is a
ggplot2
extension and is now on CRAN. Please install the stable version in
R
by running:
install.packages("ggparliament")

To install the package from source:

devtools::install_github("robwhickman/ggparliament")

Inspiration from this package comes from: parliamentdiagram, which is used on Wikipedia, parliament-svg, which is a javascript clone, and a discussion on StackOverflow, which provided some of the code for part for the "arc" representations used in this package.

If you have any issues, please note the problem and inform us!

Election data

ggparliament
provides election data from the following countries.
election_data %>% 
  distinct(year, country, house) %>% 
  arrange(country, year)
## # A tibble: 39 x 3
##    country    year house          
##                    
##  1 Australia  2010 Representatives
##  2 Australia  2010 Senate         
##  3 Australia  2013 Representatives
##  4 Australia  2013 Senate         
##  5 Australia  2016 Representatives
##  6 Australia  2016 Senate         
##  7 Australia  2019 Representatives
##  8 Australia  2019 Senate         
##  9 Chile      2009 Diputados      
## 10 Chile      2009 Senadores      
## # … with 29 more rows

We also provide the following vignettes for further explanation:

  1. Basic parliament plots
  2. Labelling parties
  3. Drawing the majority threshold line
  4. Highlighting parties in power
  5. Faceting legislatures
  6. Emphasizing certain seats
  7. Visualizaing overhang seats in MMP electoral systems
  8. Arranging seat order in ggparliament plots.

Quick

ggparliament
examples can be viewed below.

Semicircle parliament

EU, France, United States, and so on...

Plot of US House of Representatives

#filter the election data for the most recent US House of Representatives
us_house %
  filter(country == "USA" &
    year == 2016 &
    house == "Representatives")

us_house % filter(country == "USA" & year == 2016 & house == "Senate")

us_senate

representatives 

plot of chunk unnamed-chunk-6

Plot of US Senate

senate 

plot of chunk unnamed-chunk-7

Plot of German Bundestag

germany %
  filter(year == 2017 & 
           country == "Germany") 

germany

plot of chunk unnamed-chunk-8

Opposing Benches Parliament

United Kingdom

#data preparation
uk_17 % 
  filter(country == "UK" & 
           year == "2017") %>% 
  parliament_data(election_data = .,
                  party_seats = .$seats,
                  parl_rows = 12,
                  type = "opposing_benches",
                  group = .$government)


commons

plot of chunk unnamed-chunk-9

Horseshoe parliament

Australia, New Zealand

australia %
  filter(country == "Australia" &
    house == "Representatives" &
    year == 2016) %>% 
  parliament_data(election_data = .,
    party_seats = .$seats,
    parl_rows = 4,
    type = "horseshoe")

Plot of Australian parliament

au_rep 

plot of chunk unnamed-chunk-11

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.