Global Energy Use and Poverty
Graphs of global energy use, electricity use, CO2 emissions, GDP, and poverty using data from Our World in Data and IEA
Data
OWID - Energy production and consumption
OWID - CO2 emissions per capita
OWID - Extreme poverty & literacy
Prepare Data
# devtools::install_github("derekmichaelwright/agData")
library(agData)
library(plotly)
library(htmlwidgets)
library(gganimate)# Prep data
myCaption_OWID <- "derekmichaelwright.github.io/dblogr/blog/world_energy | Data: OurWorldInData"
myCaption_IEA <- "derekmichaelwright.github.io/dblogr/blog/world_energy | Data: IEA"
myItems <- c("Other", "Biofuels", "Solar", "Wind",
"Hydro", "Nuclear", "Gas", "Oil", "Coal", "Biomass")
myColors <- c("burlywood3", "darkseagreen4","darkgoldenrod2","steelblue",
"darkred", "darkblue", "slategray3",
"black", "grey50", "darkgreen")
d1 <- read.csv("global-energy-substitution.csv")
colnames(d1)[4:13] <- myItems
myItems <- myItems[c(1:4,6,5,7:10)]
#
d1 <- d1 %>% gather(Source, Value, 4:13) %>%
mutate(Source = factor(Source, levels = myItems)) %>%
group_by(Year) %>%
mutate(Total = sum(Value),
Percent = 100 * Value / Total) %>%
ungroup()
#
d2 <- read.csv("per-capita-energy-use.csv") %>%
mutate(Unit = "kWh per person") %>%
rename(Area=Entity, Value=4)
#
oldnames <- c("United States", "South Korea", "Brunei")
newnames <- c("USA", "Republic of Korea", "Brunei Darussalam")
d3 <- read.csv("consumption-co2-per-capita-vs-gdppc.csv") %>%
select(Country=Entity, Year,
CO2=Per.capita.consumption.based.CO..emissions,
GDP=GDP.per.capita..PPP..constant.2017.international...,
Population=Population..historical.) %>%
mutate(Country = plyr::mapvalues(Country, oldnames, newnames)) %>%
left_join(agData_FAO_Country_Table, by = "Country") %>%
filter(!(is.na(GDP) & is.na(CO2) & is.na(Population)))
#
d4 <- read.csv("world-population-in-extreme-poverty-absolute.csv") %>%
rename(`Not in extreme poverty` = 4,
`Living in extreme poverty` = 5) %>%
mutate(Total = `Not in extreme poverty` + `Living in extreme poverty`) %>%
gather(Measurement, Value, 4:5) %>%
mutate(Percent = 100 * Value / Total)
#
d5 <- read.csv("literate-and-illiterate-world-population.csv") %>%
rename(Literate = 4,
Iliterate = 5) %>%
gather(Measurement, Percent, 4:5)
#
d6 <- read.csv("API_EG.USE.ELEC.KH.PC_DS2_en_csv_v2_2076.csv", skip = 4) %>%
gather(Year, Value, 5:ncol(.)) %>%
mutate(Year = as.numeric(gsub("X","",Year))) %>%
filter(!is.na(Value))Global Energy by Source
Consumption
All Data
# Plot
mp <- ggplot(d1, aes(x = Year, y = Value / 1000, fill = Source)) +
geom_area(alpha = 0.7, color = alpha("black",0.7), lwd = 0.3) +
scale_fill_manual(name = NULL, values = myColors) +
scale_y_continuous(expand = c(0,0), limits = c(0,190),
minor_breaks = seq(0,200,10)) +
scale_x_continuous(breaks = seq(1800, 2030, by = 50), expand = c(0.005,0),
minor_breaks = seq(1800, 2030, by = 10)) +
guides(fill = guide_legend(override.aes = list(lwd = 0.4))) +
theme_agData() +
labs(title = "Global Energy Consumption",
y = "Thousand TWH", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_1_01.png", mp, width = 8, height = 4)> 1950
# Prep data
xx <- d1 %>% filter(Year > 1949)
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value / 1000, fill = Source)) +
geom_area(alpha = 0.7, color = alpha("black",0.7), lwd = 0.3) +
scale_fill_manual(name = NULL, values = myColors) +
scale_y_continuous(expand = c(0,0), limits = c(0,190),
minor_breaks = seq(0, 200, by = 10)) +
scale_x_continuous(breaks = seq(1950, 2030, by = 10), expand = c(0.005,0),
minor_breaks = seq(1950, 2030, by = 5)) +
guides(fill = guide_legend(override.aes = list(lwd = 0.4))) +
theme_agData() +
labs(title = "Global Energy Consumption",
y = "Thousand TWH", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_1_02.png", mp, width = 8, height = 4)Line
# Prep data
myOrder <- c(8,9,7,10,6,5,4,3,1,2)
xx <- d1 %>% filter(Year > 1949) %>%
mutate(Source = factor(Source, levels = myItems[myOrder]))
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value / 1000, color = Source)) +
geom_line(size = 1.5, alpha = 0.7) +
scale_color_manual(name = NULL, values = myColors[myOrder]) +
scale_y_continuous(minor_breaks = seq(0, 60, by = 10)) +
scale_x_continuous(breaks = seq(1950, 2030, by = 10), expand = c(0.005,0)) +
theme_agData() +
labs(title = "Global Energy Consumption",
y = "Thousand TWH", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_1_03.png", mp, width = 8, height = 4)Select Years
# Prep data
xx <- d1 %>% filter(Year %in% c(1800, 1850, 1900, 1950, 1975, 2000, 2021))
# Plot
mp <- ggplot(xx, aes(x = 1, y = Value / 1000, fill = Source)) +
geom_col(color = "black", alpha = 0.7, lwd = 0.3) +
scale_fill_manual(name = NULL, values = myColors) +
scale_y_continuous(expand = c(0.01,0), minor_breaks = seq(0,180,10)) +
facet_grid(. ~ Year) +
guides(fill = guide_legend(override.aes = list(lwd = 0.4))) +
theme_agData_col(axis.text.x = element_blank(),
axis.ticks.x = element_blank()) +
labs(title = "Global Energy Consumption",
y = "Thousand TWH", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_1_04.png", mp, width = 6, height = 4)Fossil Fuels
Stacked
# Prep data
xx <- d1 %>% filter(Source %in% myItems[7:9])
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value / 1000, fill = Source)) +
geom_area(alpha = 0.7, color = "black") +
scale_fill_manual(name = NULL, values = myColors[9:7], breaks = myItems[9:7]) +
scale_y_continuous(breaks = seq(0, 160, by = 20), limits = c(0,150),
minor_breaks = seq(0, 150, by = 10), expand = c(0,0)) +
scale_x_continuous(breaks = seq(1800, 2020, by = 50), expand = c(0.005,0),
minor_breaks = seq(1800, 2020, by = 10)) +
theme_agData() +
guides(fill = guide_legend(reverse=T)) +
labs(title = "Global Consumption of Fossil Fuels",
y = "Thousand TWH", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_1_05.png", mp, width = 6, height = 4)Facetted
# Prep data
xx <- d1 %>% filter(Source %in% myItems[9:7]) %>%
mutate(Source = factor(Source, levels = myItems[9:7]))
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value / 1000, fill = Source)) +
geom_area(alpha = 0.7, color = "black") +
scale_fill_manual(name = NULL, values = myColors[9:7]) +
facet_wrap(Source ~ .) +
scale_y_continuous(breaks = seq(0, 60, by = 10), limits = c(0,55),
minor_breaks = seq(0, 60, by = 5), expand = c(0,0)) +
scale_x_continuous(breaks = seq(1800, 2020, by = 50), expand = c(0.01,0),
minor_breaks = seq(1800, 2020, by = 10)) +
theme_agData(legend.position = "none") +
labs(title = "Global Consumption of Fossil Fuels",
y = "Thousand TWH", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_1_06.png", mp, width = 6, height = 3)Renewables
# Prep data
xx <- d1 %>% filter(Source %in% myItems[1:6]) %>%
mutate(Source = factor(Source, levels = myItems[6:1]))
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value / 1000, fill = Source)) +
geom_area(alpha = 0.7, color = "black") +
scale_fill_manual(name = NULL, values = myColors[6:1]) +
facet_wrap(Source ~ .) +
scale_y_continuous(breaks = seq(0, 11, by = 2),
minor_breaks = seq(0, 11, by = 1)) +
scale_x_continuous(breaks = seq(1800, 2020, by = 50),
minor_breaks = seq(1800, 2020, by = 10)) +
theme_agData(legend.position = "none") +
labs(title = "Global Consumption of \"Green\" Energy",
y = "Thousand TWH", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_1_07.png", mp, width = 6, height = 4)Bar Animation
# Prep data
xx <- d1 %>% filter(Year > 1870)
# Plot
mp <- ggplot(xx, aes(x = 1, y = Value / 1000, fill = Source)) +
geom_col(color = "black", alpha = 0.7) +
scale_fill_manual(name = NULL,
values = rev(myColors), breaks = rev(myItems)) +
scale_y_continuous(expand = c(0,0)) +
theme_agData(legend.position = "bottom",
axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
coord_flip() +
guides(fill = guide_legend(nrow = 1)) +
labs(title = "Global Energy Consumption - {round(frame_time)}",
y = "Thousand TWH", x = NULL, caption = myCaption_OWID) +
transition_time(Year)
anim_save("world_energy_gif_1_01.gif", mp,
nframes = 300, fps = 10, end_pause = 30,
width = 1200, height = 300, res = 150, units = "px")Projections
Fossil Fuels
# Prep data
xx <- d1 %>% filter(Source %in% myItems[9:7], Year > 1950) %>%
mutate(Source = factor(Source, levels = myItems[9:7]))
fit1 <- lm(Value ~ Year, data = xx %>% filter(Source == "Coal"))
fit2 <- lm(Value ~ Year, data = xx %>% filter(Source == "Oil"))
fit3 <- lm(Value ~ Year, data = xx %>% filter(Source == "Gas"))
x1 <- data.frame(Year = c(1950, 2050), Source = "Coal")
x1$Value <- predict(fit1, newdata = x1)
x2 <- data.frame(Year = c(1950, 2050), Source = "Oil")
x2$Value <- predict(fit2, newdata = x2)
x3 <- data.frame(Year = c(1950, 2050), Source = "Gas")
x3$Value <- predict(fit3, newdata = x3)
yy <- rbind(x1, x2, x3)
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value / 1000, color = Source)) +
geom_line(alpha = 0.7, lwd = 1) +
geom_line(data = yy, lwd = 0.5, lty = 2, alpha = 0.7) +
scale_color_manual(name = NULL, values = myColors[9:7]) +
scale_x_continuous(breaks = seq(1950, 2050, by = 10),
minor_breaks = seq(1950, 2050, by = 10)) +
theme_agData(legend.position = "bottom") +
labs(title = "Global Consumption of Fossil Fuels",
y = "Thousand TWH", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_2_01.png", mp, width = 6, height = 4)Renewables
# Prep data
xx <- d1 %>% filter(Source == "Nuclear", Year > 1970 & Year < 1990)
fit1 <- lm(Value ~ Year, data = xx)
xx <- d1 %>% filter(Source == "Hydro", Year > 1950)
fit2 <- lm(Value ~ Year, data = xx)
xx <- d1 %>% filter(Source == "Wind", Year > 2010)
fit3 <- lm(Value ~ Year, data = xx)
xx <- d1 %>% filter(Source == "Solar", Year > 2015)
fit4 <- lm(Value ~ Year, data = xx)
xx <- d1 %>% filter(Source == "Biofuels", Year > 2010)
fit5 <- lm(Value ~ Year, data = xx)
xx <- d1 %>% filter(Source == "Other", Year > 2010)
fit6 <- lm(Value ~ Year, data = xx)
#
x1 <- data.frame(Year = c(1970, 2050), Source = "Nuclear")
x1$Value <- predict(fit1, newdata = x1)
x2 <- data.frame(Year = c(1950, 2050), Source = "Hydro")
x2$Value <- predict(fit2, newdata = x2)
x3 <- data.frame(Year = c(2010, 2050), Source = "Wind")
x3$Value <- predict(fit3, newdata = x3)
x4 <- data.frame(Year = c(2015, 2050), Source = "Solar")
x4$Value <- predict(fit4, newdata = x4)
x5 <- data.frame(Year = c(2010, 2050), Source = "Biofuels")
x5$Value <- predict(fit5, newdata = x5)
x6 <- data.frame(Year = c(2010, 2050), Source = "Other")
x6$Value <- predict(fit6, newdata = x6)
#
yy <- rbind(x1, x2, x3, x4, x5, x6)
xx <- d1 %>% filter(Year > 1950, Source %in% myItems[1:6])
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value / 1000, color = Source)) +
geom_line(alpha = 0.7, lwd = 1) +
geom_line(data = yy, lwd = 0.5, lty = 2, alpha = 0.7) +
facet_wrap(Source ~ ., scales = "free_y") +
scale_color_manual(name = NULL, values = myColors) +
scale_x_continuous(breaks = seq(1950, 2050, by = 20),
minor_breaks = seq(1950, 2050, by = 10)) +
theme_agData(legend.position = "none",
axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = "Global Consumption of \"Green\" Energy",
y = "Thousand TWH", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_2_02.png", mp, width = 6, height = 4)Nuclear Energy
# Prep data
xx <- d1 %>% filter(Source == "Nuclear", Year > 1970 & Year < 1990)
fit1 <- lm(Value ~ Year, data = xx)
#
yy <- data.frame(Year = c(1970, 2050), Source = "Nuclear")
yy$Value <- predict(fit1, newdata = yy)
#
xx <- d1 %>% filter(Year > 1950, Source == "Nuclear")
# Plot
mp <- ggplot(xx, aes(x = Year, y = Value / 1000, color = Source)) +
geom_line(alpha = 0.7, lwd = 1) +
geom_line(data = yy, lwd = 0.5, lty = 2, alpha = 0.7) +
facet_wrap(Source ~ ., scales = "free_y") +
scale_color_manual(name = NULL, values = "darkred") +
scale_x_continuous(breaks = seq(1950, 2050, by = 20),
minor_breaks = seq(1950, 2050, by = 10)) +
theme_agData(legend.position = "none",
axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(title = "Global Consumption of Nuclear Energy",
y = "Thousand TWH", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_2_03.png", mp, width = 6, height = 4)Percent
All Data
# Plot
mp <- ggplot(d1, aes(x = Year, y = Percent, fill = Source)) +
geom_area(alpha = 0.7, color = "black", lwd = 0.2) +
scale_fill_manual(name = NULL, values = myColors) +
scale_y_continuous(breaks = seq(0,100,10), expand = c(0,0)) +
scale_x_continuous(breaks = seq(1800, 2020, by = 50), expand = c(0,0),
minor_breaks = seq(1800, 2020, by = 10)) +
guides(fill = guide_legend(override.aes = list(lwd = 0.4))) +
theme_agData() +
labs(title = "Global Energy Consumption",
y = "Percent of Total Energy Use", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_3_01.png", mp, width = 8, height = 4)> 2005
# Prep data
xx <- d1 %>% filter(Year >= 2005)
# Plot
mp <- ggplot(xx, aes(x = Year, y = Percent, fill = Source)) +
geom_area(alpha = 0.7, color = "black", lwd = 0.2) +
scale_fill_manual(name = NULL, values = myColors) +
scale_y_continuous(breaks = seq(0,100,10), expand = c(0,0)) +
scale_x_continuous(breaks = seq(2005, 2025, by = 5), expand = c(0,0),
minor_breaks = 2005:2025) +
guides(fill = guide_legend(override.aes = list(lwd = 0.4))) +
theme_agData() +
labs(title = "Global Energy Consumption",
y = "Percent of Total Energy Use", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_3_02.png", mp, width = 8, height = 4)Fossil Fuels
# Prep data
xx <- d1 %>% filter(Source %in% myItems[9:7]) %>%
mutate(Source = factor(Source, levels = myItems[9:7]))
# Plot
mp <- ggplot(xx, aes(x = Year, y = Percent, fill = Source)) +
geom_area(alpha = 0.7, color = "black") +
scale_fill_manual(name = NULL, values = myColors[9:7]) +
facet_wrap(Source ~ .) +
scale_y_continuous(breaks = seq(0, 60, by = 10),
minor_breaks = seq(0, 60, by = 5)) +
scale_x_continuous(breaks = seq(1800, 2020, by = 50),
minor_breaks = seq(1800, 2020, by = 10)) +
theme_agData(legend.position = "none") +
labs(title = "Global Consumption of Fossil Fuels", x = NULL,
y = "Percent of Total Energy Use", caption = myCaption_OWID)
ggsave("world_energy_3_03.png", mp, width = 6, height = 3)Renewables
# Prep data
xx <- d1 %>% filter(Source %in% myItems[1:6], Year > 1850) %>%
mutate(Source = factor(Source, levels = rev(myItems[c(1:4,6,5)])))
# Plot
mp <- ggplot(xx, aes(x = Year, y = Percent, fill = Source)) +
geom_area(alpha = 0.7, color = "black", lwd = 0.2) +
scale_fill_manual(name = NULL, values = rev(myColors[c(1:4,6,5)])) +
facet_wrap(Source ~ .) +
scale_x_continuous(breaks = seq(1850, 2020, by = 50),
minor_breaks = seq(1850, 2020, by = 10)) +
theme_agData(legend.position = "none") +
labs(title = "Global Consumption of \"Green\" Energy",
y = "Percent of Total Energy Use", x = NULL, caption = myCaption_OWID)
ggsave("world_energy_3_04.png", mp, width = 6, height = 4)2021
# Prep data
xx <- d1 %>% filter(Year == 2021) %>%
mutate(Source = factor(Source, levels = myItems[c(9:1,10)]))
# Plot
mp <- ggplot(xx, aes(x = 1, y = -Percent, fill = Source)) +
geom_col(color = "black", lwd = 0.3, alpha = 0.7) +
scale_fill_manual(name = NULL, breaks = myItems[c(9:1,10)],
values = myColors[c(9:1,10)] ) +
guides(fill = guide_legend(override.aes = list(lwd = 0.4))) +
coord_polar("y", start = 0) +
theme_agData_pie() +
xlim(0.545, 1.45) +
labs(title = "Global Energy Consumption - 2021", caption = myCaption_OWID)
ggsave("world_energy_3_05.png", mp, width = 7, height = 5)Pie Animation
# Prep data
xx <- d1 %>% filter(Percent > 0)
# Plot
mp <- ggplot(xx, aes(x = "", y = -Percent, fill = Source)) +
geom_col(color = "black", alpha = 0.7) +
scale_fill_manual(name = NULL, breaks = myItems[c(9:1,10)],
values = myColors[c(9:1,10)]) +
coord_polar("y", start = 0) +
theme_agData_pie() +
labs(title = "Percent of Global Energy Consumption - {round(frame_time)}",
caption = myCaption_OWID) +
transition_time(Year)
anim_save("world_energy_gif_3_01.gif", mp,
nframes = 300, fps = 10, end_pause = 30,
width = 900, height = 700, res = 150, units = "px")Per Capita Energy Use
Select Countries
# Prep data
myAreas <- c("Canada", "United States", "China", "India", "Africa")
myColors <- c("steelblue", "darkblue", "darkred", "darkorange", "darkgreen")
xx <- d2 %>% filter(Area %in% myAreas) %>%
mutate(Area = factor(Area, levels = myAreas))
mp <- ggplot(xx, aes(x = Year, y = Value / 1000, color = Area)) +
geom_line(linewidth = 1.5, alpha = 0.7) +
scale_color_manual(name = NULL, values = myColors) +
theme_agData() +
labs(title = "Per Capita Energy Consumption", x = NULL,
y = "Thousand kWh Per Person", caption = myCaption_OWID)
ggsave("world_energy_4_01.png", mp, width = 6, height = 4)Canada vs China
# Prep data
myAreas <- c("Canada", "China")
myColors <- c("steelblue", "darkred")
xx <- d2 %>% filter(Area %in% myAreas) %>%
mutate(Area = factor(Area, levels = myAreas))
# Plot
mp2 <- ggplot(xx, aes(x = Year, y = Value / 1000, color = Area)) +
geom_line(alpha = 0.7, lwd = 1.5) +
scale_color_manual(name = NULL, values = myColors) +
theme_agData() +
labs(title = "B) Propaganda For China", x = NULL,
y = "Thousand kWh Per Person", caption = myCaption_OWID)
mp1 <- mp2 + facet_wrap(Area ~ ., scales = "free_y") +
labs(title = "A) Propaganda For Canada", caption = NULL)
mp <- ggarrange(mp1, mp2, ncol = 1, common.legend = T, legend = "bottom")
ggsave("world_energy_4_02.png", mp, width = 6, height = 5, bg = "white")CO2 vs GDP
1990
# Prep data
xx <- d3 %>% filter(Year == 1990, !is.na(Region), !is.na(CO2), !is.na(GDP))
myColors <- c("darkgreen", "darkblue", "darkred","darkorange", "purple")
r2 <- round(cor(xx$CO2, xx$GDP)^2, 2)
mm <- round(summary(lm(data = xx, GDP / 1000 ~ CO2))$coefficients[2], 1)
# Plot
mp <- ggplot(xx, aes(x = CO2, y = GDP / 1000)) +
geom_point(aes(color = Region, size = Population), alpha = 0.7) +
geom_smooth(method = "lm", se = F, color = "black") +
geom_label(x = 5, y = 100, label = paste("italic(R)^2 == ", r2), parse = T) +
geom_label(x = 5, y = 85, label = paste("italic(m) == ", mm), parse = T) +
facet_grid(. ~ Year) +
scale_color_manual(name = NULL, values = myColors) +
guides(size = F) +
ylim(c(0, 125)) + xlim(c(0, 40)) +
theme_agData() +
labs(title = "Carbon Emmissions and GDP",
y = "GDP Per Capita (int.-$ x1000)",
x = "Per Capita Consumption-Based CO2 emissions",
caption = myCaption_OWID)
ggsave("world_energy_5_01.png", mp, width = 6, height = 4)2018
# Prep data
xx <- d3 %>% filter(Year == 2018, !is.na(Region), !is.na(CO2), !is.na(GDP))
myColors <- c("darkgreen", "darkblue", "darkred","darkorange", "purple")
r2 <- round(cor(xx$CO2, xx$GDP)^2, 2)
mm <- round(summary(lm(data = xx, GDP / 1000 ~ CO2))$coefficients[2], 1)
# Plot
mp <- ggplot(xx, aes(x = CO2, y = GDP / 1000)) +
geom_point(aes(color = Region, size = Population, key1 = Country), alpha = 0.7) +
geom_smooth(method = "lm", se = F, color = "black") +
geom_label(x = 5, y = 100, label = paste("italic(R)^2 == ", r2), parse = T) +
geom_label(x = 5, y = 85, label = paste("italic(m) == ", mm), parse = T) +
facet_grid(. ~ Year) +
scale_color_manual(name = NULL, values = myColors) +
guides(size = F) +
ylim(c(0, 125)) + xlim(c(0, 40)) +
theme_agData() +
labs(title = "Carbon Emmissions and GDP",
y = "GDP Per Capita (int.-$ x1000)",
x = "Per Capita Consumption-Based CO2 Emissions",
caption = myCaption_OWID)
ggsave("world_energy_5_02.png", mp, width = 6, height = 4)1990 vs 2018
# Prep data
xx <- d3 %>%
filter(Year %in% c(1990, 2018), !is.na(Region), !is.na(CO2), !is.na(GDP))
myColors <- c("darkgreen", "darkblue", "darkred","darkorange", "purple")
# Plot
mp <- ggplot(xx, aes(x = CO2, y = GDP / 1000)) +
geom_point(aes(color = Region, size = Population), alpha = 0.7) +
geom_smooth(method = "lm", se = F, color = "black") +
facet_grid(. ~ Year) +
scale_color_manual(name = NULL, values = myColors) +
guides(size = F) +
ylim(c(0, 125)) + xlim(c(0, 40)) +
theme_agData() +
labs(title = "Carbon Emmissions and GDP",
y = "GDP Per Capita (int.-$ x1000)",
x = "Per Capita Consumption-Based CO2 Emissions",
caption = myCaption_OWID)
ggsave("world_energy_5_03.png", mp, width = 8, height = 4)