ggparliament
ggparliament: A ggplot2 extension for parliament plots in R - Published in JOSS (2019)
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
Repository
Simple parliament plots using ggplot2
Basic Info
- Host: GitHub
- Owner: zmeers
- License: other
- Language: R
- Default Branch: master
- Homepage: https://zmeers.github.io/ggparliament/
- Size: 41.4 MB
Statistics
- Stars: 155
- Watchers: 4
- Forks: 15
- Open Issues: 10
- Releases: 1
Topics
Metadata Files
README.md

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:
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:
- Basic parliament plots
- Labelling parties
- Drawing the majority threshold line
- Highlighting parties in power
- Faceting legislatures
- Emphasizing certain seats
- Visualizaing overhang seats in MMP electoral systems
- 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 ```

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

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") +
themeggparliament(legend = TRUE) +
scalecolourmanual(values = germany$colour,
limits = germany$party_short)
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 ```

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 ```

Owner
- Name: Zoe Meers
- Login: zmeers
- Kind: user
- Location: Sydney, AUS
- Company: @Canva
- Website: https://zmeers.github.io
- Twitter: zoe_meers
- Repositories: 1
- Profile: https://github.com/zmeers
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
Top Committers
| Name | 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
Pull Request Labels
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
- Documentation: https://pkg.go.dev/github.com/zmeers/ggparliament#section-documentation
- License: other
-
Latest release: v2.1.0+incompatible
published about 7 years ago
Rankings
Dependencies
- 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