Skip to content

Commit

Permalink
add figure examples for ParlGov import
Browse files Browse the repository at this point in the history
  • Loading branch information
hdigital committed Jun 27, 2021
1 parent 32d4773 commit 5e74ff0
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
Binary file added import/parlgov/parlgov-map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions import/parlgov/parlgov.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,43 @@ parlgov_out <-
filter(share_max >= 1 | election_n >= 3 | cabinet_n >= 1)

write_csv(parlgov_out, "parlgov.csv", na = "")


# Figure map ----

library(sf)

map <- read_rds("../worldmap.rds") # Natural Earth based world map

map_pa <-
map %>%
inner_join(parlgov_out %>% count(country, name = "parties"))

pl <- ggplot() +
geom_sf(data = map, lwd = 0.1, fill = "grey85") +
geom_sf(data = map_pa, aes(fill = parties), lwd = 0.25) +
# coord_sf(crs = "+proj=robin") + # World
coord_sf(crs = "+proj=lcc +lat_1=43 +lat_2=62 +lat_0=30 +lon_0=10", # LCC Europe parameters
xlim = c(-1700000, 1750000), ylim = c(750000, 4000000)) + # set map limits
scale_fill_gradient2() +
theme_bw()

print(pl)
ggsave("parlgov-map.png", pl, width = 8, height = 6)


# Figure bar chart ----

pl_dt <-
parlgov_out %>%
left_join(party_pg %>% select(country_name, party_id)) %>%
mutate(country_name = fct_infreq(country_name) %>% fct_rev())

pl <-
ggplot(pl_dt, aes(x = country_name)) +
geom_bar() +
coord_flip() +
theme(axis.title.x = element_blank(), axis.title.y = element_blank())

print(pl)
ggsave("parlgov.png", pl, width = 20, height = 15, units = "cm")
Binary file added import/parlgov/parlgov.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions import/parlgov/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ Döring, Holger and Philip Manow. 2020. Parliaments and governments database (Pa
+ < 3 election results
+ not in cabinet
+ see `parlgov.R`

---

![](parlgov-map.png)

![](parlgov.png)
5 changes: 2 additions & 3 deletions import/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ Template for dataset readme.md files
## Todo later (optional)

+ (...)
---

_add figure for dataset if feasible_
---

`ggsave(..., width = 20, height = 15, units = "cm")`
_add figure for dataset if feasible (see ParlGov examples)_

```

Expand Down
Binary file added import/worldmap.rds
Binary file not shown.

0 comments on commit 5e74ff0

Please sign in to comment.