From 735df0cfe943d35e6b4983366209a8e767e20e94 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 18 Mar 2026 15:11:58 -0600 Subject: [PATCH] Improving figures --- Visuals.r | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Visuals.r b/Visuals.r index 0e3cfd4..e83add4 100644 --- a/Visuals.r +++ b/Visuals.r @@ -1,5 +1,7 @@ library(tidyverse) #install.packages("paletteer") + +install.packages("waffle") library(scales) library(paletteer) DATA_DIR <- 'Results/REMI_Output/' @@ -50,6 +52,20 @@ OUTPUT_PLOT dev.off() ################### INDUSTRY_JOBS <- read_csv(paste0(DATA_DIR,'Employment- By Industry - Employment by Industry.csv'),skip=5) %>% pivot_longer(c(-Industry,-Units),names_to="Year") %>% mutate(Jobs=parse_number(value),Year=parse_number(Year)) %>% select(-value) %>% filter(Industry!='All Industries') %>% select(-Units) %>% filter(Year>=2029) +INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Data processing, hosting, and related services; Other information services',"Data processing",INDUSTRY_JOBS$Industry) +INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Professional, scientific, and technical services',"Technical services",INDUSTRY_JOBS$Industry) +INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Administrative and support services',"Administrative services",INDUSTRY_JOBS$Industry) +INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='State and Local Government',"Government",INDUSTRY_JOBS$Industry) +INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Food services and drinking places',"Restaurants",INDUSTRY_JOBS$Industry) +INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Other transportation equipment manufacturing',"Equipment manufacturing",INDUSTRY_JOBS$Industry) +INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Repair and maintenance',"maintenance",INDUSTRY_JOBS$Industry) + + + + + + + INDUSTRY_JOBS <- INDUSTRY_JOBS %>% group_by(Year) %>% mutate(Rank=rank(-Jobs)) %>% mutate(Rank=ifelse(Rank>10,11,Rank),Industry=ifelse(Rank==11,"Other",Industry)) %>% group_by(Year,Industry,Rank) %>% summarize(Jobs=sum(Jobs)) %>% ungroup(Industry,Rank) %>% arrange(Year,Rank) @@ -57,11 +73,12 @@ INDUSTRY_JOBS <- INDUSTRY_JOBS %>% group_by(Year) %>% mutate(Rank=rank(-Jobs) ORDER <- c(INDUSTRY_JOBS %>% filter(Industry!='Other') %>% group_by(Industry) %>% summarize(MEAN=mean(Jobs)) %>% arrange(desc(MEAN)) %>% pull(Industry) %>% unique,"Other") INDUSTRY_JOBS$Industry <- factor(INDUSTRY_JOBS$Industry,levels=ORDER) -JOB_TYPE_PLOT <- ggplot(INDUSTRY_JOBS ,aes(x=Year,y=Jobs,fill=Industry))+geom_bar(stat='identity')+ paletteer::scale_fill_paletteer_d("colorBlindness::Blue2DarkRed18Steps") -png(paste0(OUTPUT_DIR,"Job_Dist_Plot.png"), units = "in", width = 20, height = 8, res = 600) -JOB_TYPE_PLOT +JOB_TYPE_PLOT <- ggplot(INDUSTRY_JOBS ,aes(x=Year,y=Jobs,fill=Industry))+geom_bar(stat='identity')+ paletteer::scale_fill_paletteer_d("colorBlindness::Blue2DarkRed18Steps")+theme_bw()+theme(text = element_text(size = 20),legend.position = "top")+guides(fill=guide_legend(nrow=2,byrow=TRUE)) +scale_x_continuous(breaks=seq(2029,2060,by=1))+scale_y_continuous(labels = scales::comma,breaks=seq(0,3000,by=250)) +png(paste0(OUTPUT_DIR,"Job_Dist_Plot.png"), units = "in", width = 22, height = 16, res = 600) + JOB_TYPE_PLOT dev.off() -ggplot(INDUSTRY_JOBS %>% filter(Year %in% c(2032,2045)),aes(x=as.factor(Year),y=Jobs,fill=Industry))+geom_bar(stat='identity')+ paletteer::scale_fill_paletteer_d("colorBlindness::Blue2DarkRed18Steps") +ggplot(INDUSTRY_JOBS %>% filter(Year %in% c(2032,2045)),aes(x=factor(Year),y=Jobs,fill=factor(Year)))+geom_bar(stat='identity',width=0.99)+facet_wrap(.~Industry)+theme_bw() +#+ paletteer::scale_fill_paletteer_d("lisa::FridaKahlo")