-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_Wood trade network_figures.R
119 lines (83 loc) · 5.16 KB
/
3_Wood trade network_figures.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
library("plyr")
library("ggplot2")
#Import data
glo_stat2 <- read.csv("global_stats_100.csv")
glo_stat2 <- glo_stat2[,-1]
names(glo_stat2) <- c("year", "product", "cutoff_f", "cutoff", "TOTweight", "Percent", "Nvertices", "Nedges", "Modularity","Modularity_W", "Density", "Iteration")
glo_stat2 <- glo_stat2[glo_stat2$product != "Paper+-Board Ex Newsprnt",]
glo_stat2$cutoff_f <- factor(glo_stat2$cutoff_f)
glo_stat2$year <- factor(glo_stat2$year)
glo_stat2$product <- factor(glo_stat2$product)
glo_stat2$prod_year <- interaction(glo_stat2$year, glo_stat2$product)
head(glo_stat2)
#Plots for the paper
glo_stat_Y <- subset(glo_stat2, cutoff_f == "Y")
glo_stat_Y$prod_year <- interaction(glo_stat_Y$year, glo_stat_Y$product)
dim(glo_stat_Y); names(glo_stat_Y);levels(glo_stat_Y$product); head(glo_stat_Y)
#Modularity per product per year in different panels
ggplot(glo_stat_Y, aes(x = factor(year), y = Modularity)) +
geom_point(size = 2, col = "red")+
facet_wrap(~product, nrow = 4)+
theme_bw() + #nice one there is also classic, light, minimal, etc. super nice.
theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))+
labs(x="", y = "Modularity")
ggsave("Modularity.eps", width = 13, height = 15, units = "cm")
#Weighted Modularity per product per year in different panels
setEPS()
postscript("WModularity.eps", width = 7, height = 8, horizontal = FALSE, onefile = FALSE, paper = "special")
ggplot(glo_stat_Y, aes(x = factor(year), y = Modularity_W)) +
geom_point(size = 1, col = "red")+
facet_wrap(~product, nrow = 4)+
theme_bw() + #nice one there is also classic, light, minimal, etc. super nice.
theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))+
labs(x="", y = "Weighted Modularity")
dev.off()
#ggsave("Weighted Modularity.eps", width = 13, height = 15, units = "cm")
#Modularity per product per year in one panel
ggplot(glo_stat_Y, aes(x = prod_year, y = Modularity, col = factor(product))) + geom_point() +
labs(y="Modularity") + theme_classic() + theme(legend.title=element_blank(), legend.position="bottom", axis.title.x = element_blank(), axis.text.x=element_blank(),axis.ticks.x = element_blank() )
ggplot(glo_stat_Y, aes(x = prod_year, y = Modularity_W, col = factor(product))) + geom_point() +
labs(y="Weighted Modularity") + theme_classic() + theme(legend.title=element_blank(), legend.position="bottom", axis.title.x = element_blank(), axis.text.x=element_blank(),axis.ticks.x = element_blank() )
#Additional plots for the SI
ggplot(glo_stat2, aes(x = factor(year), y = Modularity_W, colour = cutoff_f)) +
geom_point(size = 2)+ scale_colour_discrete(name="Cutoff", labels=c("No", "Yes"))+
facet_wrap(~product, nrow = 4)+
theme_bw() + #nice one there is also classic, light, minimal, etc. super nice.
theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))+
labs(x="", y = "Weighted Modularity")
ggplot(glo_stat2, aes(x = factor(year), y = Density, colour = cutoff_f)) +
geom_point(size = 2)+ scale_colour_discrete(name="Cutoff", labels=c("No", "Yes"))+
facet_wrap(~product, nrow = 4)+
theme_bw() + #nice one there is also classic, light, minimal, etc. super nice.
theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))+
labs(x="", y = "Density")
ggplot(glo_stat2, aes(x = factor(year), y = Modularity, colour = cutoff_f)) +
geom_point(size = 2)+ scale_colour_discrete(name="Cutoff", labels=c("No", "Yes"))+
facet_wrap(~product, nrow = 4)+
theme_bw() + #nice one there is also classic, light, minimal, etc. super nice.
theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))+
labs(x="", y = "Modularity")
ggplot(glo_stat2, aes(x = factor(year), y = TOTweight, colour = cutoff_f)) +
geom_point(size = 2)+ scale_colour_discrete(name="Cutoff", labels=c("No", "Yes"))+
facet_wrap(~product, nrow = 4)+
theme_bw() + #nice one there is also classic, light, minimal, etc. super nice.
theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))+
labs(x="", y = "Total Weight")
ggplot(glo_stat2, aes(x = factor(year), y = Percent, colour = cutoff_f)) +
geom_point(size = 2)+ scale_colour_discrete(name="Cutoff", labels=c("No", "Yes"))+
facet_wrap(~product, nrow = 4)+
theme_bw() + #nice one there is also classic, light, minimal, etc. super nice.
theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))+
labs(x="", y = "Percent")
ggplot(glo_stat2, aes(x = factor(year), y = Nvertices, colour = cutoff_f)) +
geom_point(size = 2)+ scale_colour_discrete(name="Cutoff", labels=c("No", "Yes"))+
facet_wrap(~product, nrow = 4)+
theme_bw() + #nice one there is also classic, light, minimal, etc. super nice.
theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))+
labs(x="", y = "Number of vertices")
ggplot(glo_stat2, aes(x = factor(year), y = Nedges, colour = cutoff_f)) +
geom_point(size = 2)+ scale_colour_discrete(name="Cutoff", labels=c("No", "Yes"))+
facet_wrap(~product, nrow = 4)+
theme_bw() + #nice one there is also classic, light, minimal, etc. super nice.
theme(axis.text.x=element_text(angle=90, size=10, vjust=0.5))+
labs(x="", y = "Number of edges")