library(tidyverse)
library(RColorBrewer)
library(scales)
oil = read.csv("Oil_Production_Country_2022.csv")
region = read.csv("Oil_by_Region_2022.csv")
region$X2022.Production <- as.numeric(region$X2022.Production)
region <- region %>% mutate(Region = fct_reorder(Region, X2022.Production, .desc = TRUE))
ggplot(region, aes(y=X2022.Production, x=Region, fill=Region))+
geom_col()+
scale_fill_brewer(palette = "Set2") +
labs(title = "Oil by Region",
x = "Region",
y = "Production in Thousands") +
theme_classic() +
theme(legend.position = "none") +
#theme_minimal()+
geom_text(aes(label = X2022.Production), vjust = -0.3, size = 3.5, color = "black") Code
Project Code
oil$Country = as.factor(oil$Country)
oil <- oil %>% mutate(Country = fct_reorder(Country, X2022.Production, .desc = FALSE))
ggplot(oil, aes(x=X2022.Production, y=Country))+
geom_col(color='grey') +
geom_text(aes(label = X2022.Production), hjust = -0.1, size = 2) +
theme_classic() +
labs(title = "Oil by Country",
x = "Oil",
y = "Production in Thousands") oil = oil %>% mutate(perc_color = case_when(
YoY.Change >0 ~ "above",
YoY.Change <= 0 ~ "below"))
ggplot(oil, aes(x = YoY.Change, y = Country, colour=perc_color)) +
geom_point() +
scale_color_manual(values = c("above" = "blue", "below" = "red")) +
scale_x_continuous(labels = percent, breaks = seq(min(oil$YoY.Change), .13, by = 0.025))+
theme_minimal() +
theme(legend.position = "bottom") +
labs(title = "YoY Change by Country in 2022",
x = "YoY Change",
y = "Country")