Nothing
knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(ggparliament) library(dplyr) library(ggplot2) require(tidyr) require(magrittr) source("../R/parliament_data.R") source("../R/geom_parliament_seats.R") source("../R/geom_highlight_government.R") source("../R/helper_funcs.R") source("../R/draw_majoritythreshold.R") source("../R/draw_partylabels.R") source("../R/draw_majoritythreshold.R") source("../R/draw_totalseats.R") source("../R/theme_ggparliament.R") load("../R/sysdata.rda")
ggparliament
includes two functions for labelling parliament plots. The first, draw_partylabels()
, plots the abbreviated name of parties and the number of seats allocated to the party. The second function, draw_totalseats()
, plots the total number of parliamentarians in the center of the graph.
data <- election_data %>% filter(year == "2016" & country == "USA" & house == "Representatives") usa_data <- parliament_data(election_data = data, type = "semicircle", party_seats = data$seats, parl_rows = 8) ggplot(usa_data, aes(x, y, color=party_long)) + geom_parliament_seats() + labs(colour = NULL) + draw_partylabels(type = "semicircle", party_names = party_short, party_seats = seats, party_colours = colour) + scale_colour_manual(values = usa_data$colour, limits = usa_data$party_long) + theme_ggparliament(legend = FALSE)
australia <- election_data %>% filter(country == "Australia" & house == "Representatives" & year == 2016) australia_horseshoe <- parliament_data(election_data = australia, party_seats = australia$seats, parl_rows = 4, type = "horseshoe") au <- ggplot(australia_horseshoe, aes(x, y, colour = party_short)) + geom_parliament_seats() + theme_ggparliament(legend = FALSE) + labs(colour = NULL, title = "Australian Parliament") + draw_partylabels(type = "horseshoe", party_names = party_short, party_seats = seats, party_colours = colour) + scale_colour_manual(values = australia$colour, limits = australia$party_short) au
data <- election_data %>% filter(year == "2016" & country == "USA" & house == "Representatives") usa_data <- parliament_data(election_data = data, type = "semicircle", party_seats = data$seats, parl_rows = 8) ggplot(usa_data, aes(x, y, color=party_long)) + geom_parliament_seats() + labs(colour = NULL) + draw_totalseats(n = 435, type = "semicircle") + scale_colour_manual(values = usa_data$colour, limits = usa_data$party_long) + theme_ggparliament(legend = FALSE)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.