Skip to content

Commit cb763d6

Browse files
committed
add map experiments
1 parent 3850c22 commit cb763d6

File tree

4 files changed

+2887
-145
lines changed

4 files changed

+2887
-145
lines changed

map-experiments.Rmd

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
title: "General statistical overviews of FILTER data"
3+
date: "`r Sys.Date()`"
4+
output:
5+
html_notebook:
6+
code_folding: hide
7+
toc: yes
8+
html_document:
9+
code_folding: hide
10+
toc: yes
11+
---
12+
13+
```{r setup, include=FALSE}
14+
knitr::opts_chunk$set(message=FALSE,dpi=300,fig.retina=2,fig.width=8)
15+
source(here::here("src/common_basis.R"))
16+
tmap_mode("plot")
17+
```
18+
19+
```{r}
20+
polygons %>%
21+
filter(map_id==1) %>%
22+
left_join(p_pl %>% count(pl_id) %>% collect()) %>%
23+
replace_na(list(n=0)) %>%
24+
group_by(pol_id, geometry) %>%
25+
summarise(n=sum(n)) %>%
26+
tm_shape() +
27+
tm_polygons(col='n', id='name', style='fisher', palette='plasma') +
28+
tm_layout(main.title="Exp-1")
29+
```
30+
31+
```{r}
32+
polygons %>%
33+
filter(map_id==0) %>%
34+
left_join(p_pl %>% count(pl_id) %>% collect()) %>%
35+
group_by(pol_id, geometry) %>%
36+
summarise(n=sum(n)) %>%
37+
tm_shape() +
38+
tm_polygons(col='n', id='name', style='fisher', palette='plasma') +
39+
tm_layout(main.title="Exp-1")
40+
```
41+
42+
```{r}
43+
polygons %>%
44+
filter(map_id==0) %>%
45+
left_join(p_pl %>% count(pl_id) %>% collect()) %>%
46+
group_by(pol_id, geometry) %>%
47+
summarise(n=sum(n)) %>%
48+
tm_shape() +
49+
tm_polygons() +
50+
tm_bubbles(size = "n", col="n") +
51+
tm_layout(main.title="Exp-1")
52+
```
53+
```{r}
54+
polygons %>%
55+
filter(map_id==1) %>%
56+
left_join(p_pl %>% count(pl_id) %>% collect()) %>%
57+
replace_na(list(n=0)) %>%
58+
group_by(pol_id, geometry) %>%
59+
summarise(n=sum(n)) %>%
60+
tm_shape(point.per="largest") +
61+
tm_polygons() +
62+
tm_bubbles(size = "n", col="n") +
63+
tm_layout(main.title="Exp-1")
64+
```
65+
66+
```{r}
67+
d <- polygons %>%
68+
filter(map_id==0) %>%
69+
left_join(p_pl %>% inner_join(poems) %>% count(collection, pl_id) %>% collect()) %>%
70+
replace_na(list(n=0)) %>%
71+
group_by(collection, pol_id, geometry) %>%
72+
summarise(n=sum(n)) %>%
73+
group_by(pol_id) %>%
74+
mutate(tn=sum(n)) %>%
75+
ungroup() %>%
76+
mutate(pol_id=str_c("p", pol_id), collection=as_factor(collection))
77+
78+
plot_cols <- coloropt_pal()(4)
79+
80+
grps <- d %>%
81+
# filter(!is.na(n)) %>%
82+
complete(nesting(pol_id,tn,geometry),collection,fill=list(n=0)) %>%
83+
group_by(pol_id)
84+
grobs <- grps %>%
85+
group_map(~ggplotGrob(ggplot(.x, aes(x="", y=n, fill=collection)) +
86+
geom_col(width=1) +
87+
scale_y_continuous(expand=c(0,0)) +
88+
scale_fill_manual(values=plot_cols) +
89+
theme_ps(plot.axes = FALSE))
90+
) %>%
91+
set_names(group_keys(grps) %>% pull())
92+
```
93+
94+
95+
```{r,fig.width=10,fig.height=14}
96+
d %>%
97+
distinct(pol_id,geometry,tn) %>%
98+
tm_shape(point.per="largest") +
99+
tm_polygons() +
100+
tm_symbols(shape="pol_id",
101+
shapes=grobs,
102+
size="tn",
103+
legend.shape.show = FALSE,
104+
legend.size.is.portrait = TRUE,
105+
shapes.legend = 22) +
106+
tm_add_legend(type="fill",
107+
col=plot_cols,
108+
labels=c("erab", "jr", "literary", "skvr"),
109+
title="Collection")
110+
111+
```
112+
113+
```{r}
114+
d %>%
115+
tm_shape() +
116+
tm_polygons() +
117+
tm_bubbles(size="n") +
118+
tm_facets(by="collection",ncol=4)
119+
```
120+

0 commit comments

Comments
 (0)