-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinePlotbyCountry 1.r
77 lines (68 loc) · 4 KB
/
linePlotbyCountry 1.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
library(ggplot2)
library(tidyverse)
co2_year_plot<-function(input, coun, year1, year2) {
plot_df = subset(input, year>=year1 & year<=year2 & co2!=0 & country == coun)
g1 = ggplot(plot_df, aes(x = year, y = co2, color = country)) + geom_line() + geom_point(size = 1, alpha = 0.8) +
ylab("co2 emission") + xlab("Year") + theme_bw() +
# scale_colour_manual(values=c(covid_col)) +
# scale_y_continuous(labels = function(l) {trans = l / 1000000; paste0(trans, "M")}) +
theme(legend.title = element_blank(), legend.position = "", plot.title = element_text(size=10),
plot.margin = margin(5, 12, 5, 5))
g1
}
co2_per_capita_plot<-function(input, coun, year1, year2) {
plot_df = subset(input, year>=year1 & year<=year2 & co2_per_capita!=0 & country == coun)
g1 = ggplot(plot_df, aes(x = year, y = co2_per_capita, color = country)) + geom_line() + geom_point(size = 1, alpha = 0.8) +
ylab("co2_per_capita") + xlab("Year") + theme_bw() +
theme(legend.title = element_blank(), legend.position = "", plot.title = element_text(size=10),
plot.margin = margin(5, 12, 5, 5))
g1
}
ch4_year_plot<-function(input, coun, year1, year2) {
plot_df = subset(input, year>=year1 & year<=year2 & methane!=0 & country == coun)
g1 = ggplot(plot_df, aes(x = year, y = methane, color = country)) + geom_line() + geom_point(size = 1, alpha = 0.8) +
ylab("methane emission") + xlab("Year") + theme_bw() +
theme(legend.title = element_blank(), legend.position = "", plot.title = element_text(size=10),
plot.margin = margin(5, 12, 5, 5))
g1
}
ch4_per_capita_plot<-function(input, coun, year1, year2) {
plot_df = subset(input, year>=year1 & year<=year2 & methane_per_capita!=0 & country == coun)
g1 = ggplot(plot_df, aes(x = year, y = methane_per_capita, color = country)) + geom_line() + geom_point(size = 1, alpha = 0.8) +
ylab("methane_per_capita") + xlab("Year") + theme_bw() +
theme(legend.title = element_blank(), legend.position = "", plot.title = element_text(size=10),
plot.margin = margin(5, 12, 5, 5))
g1
}
no2_year_plot<-function(input, coun, year1, year2) {
plot_df = subset(input, year>=year1 & year<=year2 & nitrous_oxide!=0 & country == coun)
g1 = ggplot(plot_df, aes(x = year, y = nitrous_oxide, color = country)) + geom_line() + geom_point(size = 1, alpha = 0.8) +
ylab("no2 emission") + xlab("Year") + theme_bw() +
theme(legend.title = element_blank(), legend.position = "", plot.title = element_text(size=10),
plot.margin = margin(5, 12, 5, 5))
g1
}
no2_per_capita_plot<-function(input, coun, year1, year2) {
plot_df = subset(input, year>=year1 & year<=year2 & nitrous_oxide_per_capita!=0 & country == coun)
g1 = ggplot(plot_df, aes(x = year, y = nitrous_oxide_per_capita, color = country)) + geom_line() + geom_point(size = 1, alpha = 0.8) +
ylab("no2_per_capita") + xlab("Year") + theme_bw() +
theme(legend.title = element_blank(), legend.position = "", plot.title = element_text(size=10),
plot.margin = margin(5, 12, 5, 5))
g1
}
total_ghg_plot<-function(input, coun, year1, year2) {
plot_df = subset(input, year>=year1 & year<=year2 & total_ghg!=0 & country == coun)
g1 = ggplot(plot_df, aes(x = year, y = total_ghg, color = country)) + geom_line() + geom_point(size = 1, alpha = 0.8) +
ylab("total greenhouse gas emission") + xlab("Year") + theme_bw() +
theme(legend.title = element_blank(), legend.position = "", plot.title = element_text(size=10),
plot.margin = margin(5, 12, 5, 5))
g1
}
total_ghg_per_capita<-function(input, coun, year1, year2) {
plot_df = subset(input, year>=year1 & year<=year2 & ghg_per_capita!=0 & country == coun)
g1 = ggplot(plot_df, aes(x = year, y = ghg_per_capita, color = country)) + geom_line() + geom_point(size = 1, alpha = 0.8) +
ylab("total_greenhouse_gas_per_capita") + xlab("Year") + theme_bw() +
theme(legend.title = element_blank(), legend.position = "", plot.title = element_text(size=10),
plot.margin = margin(5, 12, 5, 5))
g1
}