Skip to content

Commit 662865d

Browse files
committed
fix readme
1 parent 4f203b3 commit 662865d

File tree

3 files changed

+256
-11
lines changed

3 files changed

+256
-11
lines changed

README.Rmd

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ library(tidyr)
1616
library(ggplot2)
1717
1818
19-
# source("R/parliament_data.R")
20-
# source("R/geom_parliament_seats.R")
21-
# source("R/geom_highlight_government.R")
22-
# source("R/geom_emphasize_parliamentarians.R")
23-
# source("R/helper_funcs.R")
24-
# source("R/draw_majoritythreshold.R")
25-
# source("R/draw_partylabels.R")
26-
# source("R/draw_majoritythreshold.R")
27-
# source("R/draw_totalseats.R")
28-
# source("R/theme_ggparliament.R")
29-
# source("R/geom_parliament_bar.R")
19+
source("R/parliament_data.R")
20+
source("R/geom_parliament_seats.R")
21+
source("R/geom_highlight_government.R")
22+
source("R/geom_emphasize_parliamentarians.R")
23+
source("R/helper_funcs.R")
24+
source("R/draw_majoritythreshold.R")
25+
source("R/draw_partylabels.R")
26+
source("R/draw_majoritythreshold.R")
27+
source("R/draw_totalseats.R")
28+
source("R/theme_ggparliament.R")
29+
source("R/geom_parliament_bar.R")
3030
3131
```
3232

README.md

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,267 @@ pagetitle: README
99

1010

1111

12+
# Status
13+
[![Build Status](https://travis-ci.org/RobWHickman/ggparliament.png)](https://travis-ci.org/RobWHickman/ggparliament)
14+
![CRAN Status](https://www.r-pkg.org/badges/version/ggparliament)
15+
![Downloads](https://cranlogs.r-pkg.org/badges/grand-total/ggparliament)
16+
<img src = "man/figures/HexSticker.png" align = "right" width = "200"/>
1217

18+
# ggparliament: Parliament plots
1319

1420

21+
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.
1522

23+
This `R` package is a `ggplot2` extension and is now on CRAN. Please install the stable version in `R` by running:
1624

1725

26+
```r
27+
install.packages("ggparliament")
28+
```
1829

30+
To install the package from source:
1931

32+
```r
33+
devtools::install_github("robwhickman/ggparliament")
34+
```
2035

36+
Inspiration from this package comes from: [parliamentdiagram](https://github.com/slashme/parliamentdiagram), which
37+
is used on Wikipedia, [parliament-svg](https://github.com/juliuste/parliament-svg), which is a javascript clone, and [a discussion on StackOverflow](http://stackoverflow.com/questions/42729174/creating-a-half-donut-or-parliamentary-seating-chart), which provided some of the code for part for the "arc" representations used in this package.
2138

2239

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

2442

43+
## Election data
2544

45+
`ggparliament` provides election data from the following countries.
2646

2747

48+
```r
49+
election_data %>%
50+
distinct(year, country, house) %>%
51+
arrange(country, year)
52+
```
53+
54+
```
55+
## year country house
56+
## 1 2010 Australia Representatives
57+
## 2 2010 Australia Senate
58+
## 3 2013 Australia Representatives
59+
## 4 2013 Australia Senate
60+
## 5 2016 Australia Representatives
61+
## 6 2016 Australia Senate
62+
## 7 1990 Germany Bundestag
63+
## 8 1994 Germany Bundestag
64+
## 9 1998 Germany Bundestag
65+
## 10 2002 Germany Bundestag
66+
## 11 2005 Germany Bundestag
67+
## 12 2009 Germany Bundestag
68+
## 13 2013 Germany Bundestag
69+
## 14 2017 Germany Bundestag
70+
## 15 2007 Russia Duma
71+
## 16 2011 Russia Duma
72+
## 17 2016 Russia Duma
73+
## 18 2010 UK Commons
74+
## 19 2015 UK Commons
75+
## 20 2017 UK Commons
76+
## 21 2012 USA Senate
77+
## 22 2012 USA Representatives
78+
## 23 2014 USA Senate
79+
## 24 2014 USA Representatives
80+
## 25 2016 USA Senate
81+
## 26 2016 USA Representatives
82+
```
83+
84+
We also provide the following vignettes for further explanation:
85+
86+
1. Basic parliament plots
87+
2. Labelling parties
88+
3. Drawing the majority threshold line
89+
4. Highlighting parties in power
90+
5. Faceting legislatures
91+
6. Emphasizing certain seats
92+
7. Visualizaing overhang seats in MMP electoral systems
93+
8. Arranging seat order in ggparliament plots.
94+
95+
Quick `ggparliament` examples can be viewed below.
96+
97+
## Semicircle parliament
98+
99+
### EU, France, United States, and so on...
100+
101+
102+
### Plot of US House of Representatives
103+
104+
105+
106+
```r
107+
#filter the election data for the most recent US House of Representatives
108+
us_house <- election_data %>%
109+
filter(country == "USA" &
110+
year == 2016 &
111+
house == "Representatives")
112+
113+
us_house <- parliament_data(election_data = us_house,
114+
type = "semicircle",
115+
parl_rows = 10,
116+
party_seats = us_house$seats)
117+
118+
us_senate <- election_data %>%
119+
filter(country == "USA" &
120+
year == 2016 &
121+
house == "Senate")
122+
123+
us_senate <- parliament_data(
124+
election_data = us_senate,
125+
type = "semicircle",
126+
parl_rows = 4,
127+
party_seats = us_senate$seats)
128+
```
129+
130+
131+
```r
132+
representatives <- ggplot(us_house, aes(x, y, colour = party_short)) +
133+
geom_parliament_seats() +
134+
#highlight the party in control of the House with a black line
135+
geom_highlight_government(government == 1) +
136+
#draw majority threshold
137+
draw_majoritythreshold(n = 218, label = TRUE, type = 'semicircle')+
138+
#set theme_ggparliament
139+
theme_ggparliament() +
140+
#other aesthetics
141+
labs(colour = NULL,
142+
title = "United States House of Representatives",
143+
subtitle = "Party that controls the House highlighted.") +
144+
scale_colour_manual(values = us_house$colour,
145+
limits = us_house$party_short)
146+
147+
representatives
148+
```
149+
150+
![plot of chunk unnamed-chunk-6](figure/unnamed-chunk-6-1.png)
151+
152+
### Plot of US Senate
153+
154+
155+
```r
156+
senate <- ggplot(us_senate, aes(x, y, colour = party_long)) +
157+
geom_parliament_seats() +
158+
geom_highlight_government(government == 1) +
159+
# add bar showing proportion of seats by party in legislature
160+
geom_parliament_bar(colour = colour, party = party_long) +
161+
theme_ggparliament(legend = FALSE) +
162+
labs(colour = NULL,
163+
title = "United States Senate",
164+
subtitle = "The party that has control of the Senate is encircled in black.") +
165+
scale_colour_manual(values = us_senate$colour,
166+
limits = us_senate$party_long)
167+
senate
168+
```
169+
170+
![plot of chunk unnamed-chunk-7](figure/unnamed-chunk-7-1.png)
171+
172+
173+
### Plot of German Bundestag
174+
175+
176+
```r
177+
germany <- election_data %>%
178+
filter(year == 2017 &
179+
country == "Germany")
180+
181+
germany <- parliament_data(election_data = germany,
182+
parl_rows = 10,
183+
type = 'semicircle',
184+
party_seats = germany$seats)
185+
186+
bundestag <- ggplot(germany, aes(x, y, colour = party_short)) +
187+
geom_parliament_seats(size = 3) +
188+
labs(colour="Party") +
189+
theme_ggparliament(legend = TRUE) +
190+
scale_colour_manual(values = germany$colour,
191+
limits = germany$party_short)
192+
193+
bundestag
194+
```
195+
196+
![plot of chunk unnamed-chunk-8](figure/unnamed-chunk-8-1.png)
197+
198+
## Opposing Benches Parliament
199+
200+
201+
202+
### United Kingdom
203+
204+
205+
```r
206+
#data preparation
207+
uk_17 <- election_data %>%
208+
filter(country == "UK" &
209+
year == "2017") %>%
210+
parliament_data(election_data = .,
211+
party_seats = .$seats,
212+
parl_rows = 12,
213+
type = "opposing_benches",
214+
group = .$government)
215+
216+
217+
commons <- ggplot(uk_17, aes(x, y, colour = party_short)) +
218+
geom_parliament_seats(size = 3) +
219+
theme_ggparliament() +
220+
coord_flip() +
221+
labs(colour = NULL,
222+
title = "UK parliament in 2017") +
223+
scale_colour_manual(values = uk_17$colour,
224+
limits = uk_17$party_short)
225+
226+
commons
227+
```
228+
229+
![plot of chunk unnamed-chunk-9](figure/unnamed-chunk-9-1.png)
230+
231+
232+
233+
## Horseshoe parliament
234+
235+
### Australia, New Zealand
236+
237+
238+
```r
239+
australia <- election_data %>%
240+
filter(country == "Australia" &
241+
house == "Representatives" &
242+
year == 2016) %>%
243+
parliament_data(election_data = .,
244+
party_seats = .$seats,
245+
parl_rows = 4,
246+
type = "horseshoe")
247+
```
248+
249+
### Plot of Australian parliament
250+
251+
252+
```r
253+
au_rep <-ggplot(australia, aes(x, y, colour = party_short)) +
254+
geom_parliament_seats(size = 3.5) +
255+
geom_highlight_government(government == 1, colour = "pink", size = 4) +
256+
draw_majoritythreshold(n = 76,
257+
label = TRUE,
258+
linesize = 0.5,
259+
type = 'horseshoe') +
260+
theme_ggparliament() +
261+
theme(legend.position = 'bottom') +
262+
labs(colour = NULL,
263+
title = "Australian Parliament",
264+
subtitle = "Government circled in pink.") +
265+
scale_colour_manual(values = australia$colour,
266+
limits = australia$party_short)
267+
268+
au_rep
269+
```
270+
271+
![plot of chunk unnamed-chunk-11](figure/unnamed-chunk-11-1.png)
272+
28273

29274

30275

figure/unnamed-chunk-8-1.png

4.51 KB
Loading

0 commit comments

Comments
 (0)