ggparliament

ggparliament: A ggplot2 extension for parliament plots in R - Published in JOSS (2019)

https://github.com/zmeers/ggparliament

Science Score: 59.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
    1 of 7 committers (14.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.3%) to scientific vocabulary

Keywords

dataviz ggplot2 parliament-charts r r-package seat-count visualization
Last synced: 9 months ago · JSON representation

Repository

Simple parliament plots using ggplot2

Basic Info
Statistics
  • Stars: 155
  • Watchers: 4
  • Forks: 15
  • Open Issues: 10
  • Releases: 1
Topics
dataviz ggplot2 parliament-charts r r-package seat-count visualization
Created about 9 years ago · Last pushed 11 months ago
Metadata Files
Readme Changelog Contributing License

README.md

ggparliament: Parliament plots

CRAN Status Downloads DOI

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:

r install.packages("ggparliament")

To install the package from source:

r devtools::install_github("zmeers/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.

r 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

```r

filter the election data for the most recent US House of Representatives

ushouse <- electiondata %>% filter(country == "USA" & year == 2016 & house == "Representatives")

ushouse <- parliamentdata(electiondata = ushouse, type = "semicircle", parlrows = 10, partyseats = us_house$seats)

ussenate <- electiondata %>% filter(country == "USA" & year == 2016 & house == "Senate")

ussenate <- parliamentdata( electiondata = ussenate, type = "semicircle", parlrows = 4, partyseats = us_senate$seats) ```

```r representatives <- ggplot(ushouse, aes(x, y, colour = partyshort)) + geomparliamentseats() + #highlight the party in control of the House with a black line geomhighlightgovernment(government == 1) + #draw majority threshold drawmajoritythreshold(n = 218, label = TRUE, type = 'semicircle')+ #set themeggparliament themeggparliament() + #other aesthetics labs(colour = NULL, title = "United States House of Representatives", subtitle = "Party that controls the House highlighted.") + scalecolourmanual(values = ushouse$colour, limits = ushouse$partyshort)

representatives ```

US House of Representatives

Plot of US Senate

r senate <- ggplot(us_senate, aes(x, y, colour = party_long)) + geom_parliament_seats() + geom_highlight_government(government == 1) + # add bar showing proportion of seats by party in legislature geom_parliament_bar(colour = colour, party = party_long) + theme_ggparliament(legend = FALSE) + labs(colour = NULL, title = "United States Senate", subtitle = "The party that has control of the Senate is encircled in black.") + scale_colour_manual(values = us_senate$colour, limits = us_senate$party_long) senate

US Senate

Plot of German Bundestag

```r germany <- election_data %>% filter(year == 2017 & country == "Germany")

germany <- parliamentdata(electiondata = germany, parlrows = 10, type = 'semicircle', partyseats = germany$seats)

bundestag <- ggplot(germany, aes(x, y, colour = partyshort)) + geomparliamentseats(size = 3) + labs(colour="Party") +
theme
ggparliament(legend = TRUE) + scalecolourmanual(values = germany$colour, limits = germany$party_short)

bundestag ```

German Bundestag

Opposing Benches Parliament

United Kingdom

```r

data preparation

uk17 <- electiondata %>% filter(country == "UK" & year == "2017") %>% parliamentdata(electiondata = ., partyseats = .$seats, parlrows = 12, type = "opposing_benches", group = .$government)

commons <- ggplot(uk17, aes(x, y, colour = partyshort)) + geomparliamentseats(size = 3) + themeggparliament() + coordflip() + labs(colour = NULL, title = "UK parliament in 2017") + scalecolourmanual(values = uk17$colour, limits = uk17$party_short)

commons ```

UK Parliament

Horseshoe parliament

Australia, New Zealand

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

Plot of Australian parliament

```r aurep <-ggplot(australia, aes(x, y, colour = partyshort)) + geomparliamentseats(size = 3.5) + geomhighlightgovernment(government == 1, colour = "pink", size = 4) + drawmajoritythreshold(n = 76, label = TRUE, linesize = 0.5, type = 'horseshoe') + themeggparliament() + theme(legend.position = 'bottom') + labs(colour = NULL, title = "Australian Parliament", subtitle = "Government circled in pink.") + scalecolourmanual(values = australia$colour, limits = australia$party_short)

au_rep ```

Australian Parliament

Owner

  • Name: Zoe Meers
  • Login: zmeers
  • Kind: user
  • Location: Sydney, AUS
  • Company: @Canva

GitHub Events

Total
  • Issues event: 2
  • Watch event: 6
  • Issue comment event: 2
  • Push event: 2
  • Pull request review event: 4
  • Pull request review comment event: 2
  • Pull request event: 5
  • Fork event: 3
Last Year
  • Issues event: 2
  • Watch event: 6
  • Issue comment event: 2
  • Push event: 2
  • Pull request review event: 4
  • Pull request review comment event: 2
  • Pull request event: 5
  • Fork event: 3

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 370
  • Total Committers: 7
  • Avg Commits per committer: 52.857
  • Development Distribution Score (DDS): 0.327
Past Year
  • Commits: 15
  • Committers: 2
  • Avg Commits per committer: 7.5
  • Development Distribution Score (DDS): 0.333
Top Committers
Name Email Commits
Zoe Meers z****s@g****m 249
RobWHickman r****n@g****m 88
Thomas J. Leeper t****r@g****m 10
Dean Hansen h****n@g****m 10
Richard Martin-Nielsen r****n@a****a 5
Roberto Salas w****s@g****m 4
Zoe Meers z****s@1****u 4
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 27
  • Total pull requests: 39
  • Average time to close issues: 5 months
  • Average time to close pull requests: 9 days
  • Total issue authors: 12
  • Total pull request authors: 6
  • Average comments per issue: 2.59
  • Average comments per pull request: 0.87
  • Merged pull requests: 31
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 6
  • Average time to close issues: 3 months
  • Average time to close pull requests: 2 months
  • Issue authors: 1
  • Pull request authors: 2
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.83
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • zmeers (11)
  • RobWHickman (6)
  • Bretsy3121 (1)
  • harnagpal (1)
  • RichardMN (1)
  • lwarode (1)
  • jesbrz (1)
  • duleise (1)
  • leeper (1)
  • aidanmchugh02 (1)
  • Jazzpenner (1)
  • mpadge (1)
Pull Request Authors
  • zmeers (26)
  • RobWHickman (10)
  • deanhansen (4)
  • RichardMN (2)
  • Jazzpenner (1)
  • robsalasco (1)
Top Labels
Issue Labels
bug (5) enhancement (5) editing (2)
Pull Request Labels
enhancement (1)

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
proxy.golang.org: github.com/zmeers/ggparliament
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 9 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • dplyr * imports
  • ggplot2 * imports
  • rlang * imports
  • ggrepel * suggests
  • knitr * suggests
  • magrittr * suggests
  • markdown * suggests
  • purrr * suggests
  • rmarkdown * suggests
  • scales * suggests
  • testthat * suggests
  • tidyr * suggests