All Projects β†’ RobWHickman β†’ Ggparliament

RobWHickman / Ggparliament

Licence: other
Simple parliament plots using ggplot2

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Ggparliament

jcolors
A set of color palettes I like (or can at least tolerate)
Stars: ✭ 24 (-81.54%)
Mutual labels:  ggplot2, r-package
Ggpage
Creates Page Layout Visualizations in R πŸ“„πŸ“„πŸ“„
Stars: ✭ 306 (+135.38%)
Mutual labels:  ggplot2, dataviz
Bayesplot
bayesplot R package for plotting Bayesian models
Stars: ✭ 276 (+112.31%)
Mutual labels:  ggplot2, r-package
DataViz-Teaching
πŸ“ˆ Visualizations for DataViz Teaching
Stars: ✭ 29 (-77.69%)
Mutual labels:  ggplot2, dataviz
Tidymv
Tidy Model Visualisation for Generalised Additive Models
Stars: ✭ 25 (-80.77%)
Mutual labels:  ggplot2, r-package
Rstudio TableContest 2020
πŸ“Ί Table showing an "Overview and Series Trends of the Best TV Shows on IMDb" – My Contribution to the Rstudio Table Contest 2020
Stars: ✭ 16 (-87.69%)
Mutual labels:  ggplot2, dataviz
Ggextra
πŸ“Š Add marginal histograms to ggplot2, and more ggplot2 enhancements
Stars: ✭ 299 (+130%)
Mutual labels:  ggplot2, r-package
mapr
Map species occurrence data
Stars: ✭ 34 (-73.85%)
Mutual labels:  ggplot2, r-package
Tidybayes
Bayesian analysis + tidy data + geoms (R package)
Stars: ✭ 557 (+328.46%)
Mutual labels:  ggplot2, r-package
Naniar
Tidy data structures, summaries, and visualisations for missing data
Stars: ✭ 557 (+328.46%)
Mutual labels:  ggplot2, r-package
SWDchallenge
πŸ“ˆ My contributions to the #SWDchallenge
Stars: ✭ 20 (-84.62%)
Mutual labels:  ggplot2, dataviz
Ggpol
🌍 Parliament diagrams and more for ggplot2
Stars: ✭ 71 (-45.38%)
Mutual labels:  ggplot2, dataviz
cusumcharter
Easier CUSUM control charts. Returns simple CUSUM statistics, CUSUMs with control limit calculations, and function to generate faceted CUSUM Control Charts
Stars: ✭ 17 (-86.92%)
Mutual labels:  ggplot2, r-package
30diasdegraficos
30 tipos de grΓ‘ficos hechos con R, con datos y cΓ³digo reproducible.
Stars: ✭ 47 (-63.85%)
Mutual labels:  ggplot2, dataviz
dataviz
Course materials for Kieran Healy's rstudio::conf 2020 data visualization workshop
Stars: ✭ 75 (-42.31%)
Mutual labels:  ggplot2, dataviz
Ggpointdensity
πŸ“ˆ πŸ“Š Introduces geom_pointdensity(): A Cross Between a Scatter Plot and a 2D Density Plot.
Stars: ✭ 286 (+120%)
Mutual labels:  ggplot2, r-package
vioplot
Development version of vioplot R package (CRAN maintainer)
Stars: ✭ 25 (-80.77%)
Mutual labels:  dataviz, r-package
TDAstats
R pipeline for computing persistent homology in topological data analysis. See https://doi.org/10.21105/joss.00860 for more details.
Stars: ✭ 26 (-80%)
Mutual labels:  ggplot2, r-package
Tidytuesday
πŸ“Š My contributions to the #TidyTuesday challenge
Stars: ✭ 410 (+215.38%)
Mutual labels:  ggplot2, dataviz
Ggplot Courses
πŸ‘¨β€πŸ« ggplot2 Teaching Material
Stars: ✭ 40 (-69.23%)
Mutual labels:  ggplot2, dataviz

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          
##    <chr>     <dbl> <chr>          
##  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 <- election_data %>%
  filter(country == "USA" &
    year == 2016 &
    house == "Representatives")

us_house <- parliament_data(election_data = us_house,
  type = "semicircle",
  parl_rows = 10,
  party_seats = us_house$seats)

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

us_senate <- parliament_data(
  election_data = us_senate,
  type = "semicircle",
  parl_rows = 4,
  party_seats = us_senate$seats)
representatives <- ggplot(us_house, aes(x, y, colour = party_short)) +
  geom_parliament_seats() + 
  #highlight the party in control of the House with a black line
  geom_highlight_government(government == 1) +
  #draw majority threshold
  draw_majoritythreshold(n = 218, label = TRUE, type = 'semicircle')+
  #set theme_ggparliament
  theme_ggparliament() +
  #other aesthetics
  labs(colour = NULL, 
       title = "United States House of Representatives",
       subtitle = "Party that controls the House highlighted.") +
  scale_colour_manual(values = us_house$colour, 
                      limits = us_house$party_short) 

representatives

plot of chunk unnamed-chunk-6

Plot of US Senate

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 chunk unnamed-chunk-7

Plot of German Bundestag

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

germany <- parliament_data(election_data = germany, 
                           parl_rows = 10,
                           type = 'semicircle',
                           party_seats = germany$seats)

bundestag <- ggplot(germany, aes(x, y, colour = party_short)) +
  geom_parliament_seats(size = 3) +
  labs(colour="Party") +  
  theme_ggparliament(legend = TRUE) +
  scale_colour_manual(values = germany$colour, 
                      limits = germany$party_short) 

bundestag

plot of chunk unnamed-chunk-8

Opposing Benches Parliament

United Kingdom

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


commons <- ggplot(uk_17, aes(x, y, colour = party_short)) +
  geom_parliament_seats(size = 3) + 
  theme_ggparliament() + 
  coord_flip() + 
  labs(colour = NULL, 
       title = "UK parliament in 2017") +
  scale_colour_manual(values = uk_17$colour, 
                      limits = uk_17$party_short)

commons

plot of chunk unnamed-chunk-9

Horseshoe parliament

Australia, New Zealand

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

au_rep <-ggplot(australia, aes(x, y, colour = party_short)) +
  geom_parliament_seats(size = 3.5) + 
  geom_highlight_government(government == 1, colour = "pink", size = 4) + 
  draw_majoritythreshold(n = 76, 
                         label = TRUE, 
                         linesize = 0.5,
                         type = 'horseshoe') + 
  theme_ggparliament() +
  theme(legend.position = 'bottom') + 
  labs(colour = NULL,
       title = "Australian Parliament",
       subtitle = "Government circled in pink.") +
  scale_colour_manual(values = australia$colour, 
                      limits = australia$party_short) 

au_rep

plot of chunk unnamed-chunk-11

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].