From d52f8c76b63d0f560647d8a408e47b8e73deefd4 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 18 Mar 2026 16:51:01 -0600 Subject: [PATCH] Daily figure updates --- Visuals.r | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/Visuals.r b/Visuals.r index e83add4..c9d52dd 100644 --- a/Visuals.r +++ b/Visuals.r @@ -1,7 +1,6 @@ library(tidyverse) #install.packages("paletteer") -install.packages("waffle") library(scales) library(paletteer) DATA_DIR <- 'Results/REMI_Output/' @@ -19,9 +18,11 @@ COLORS <- rev(paletteer_d("fishualize::Alosa_fallax",n=4,direction=1)[-2]) MAX_VAL <- round(max(EMPLOY_NUM$Employment)) COOL_DOWN <- as.numeric(EMPLOY_NUM[5,3]) df <- data.frame(Year=c(2032.5,2034.25,2046,2059.8),Employment=c(MAX_VAL,COOL_DOWN,791+20,743+20),text=c("Peak of 2,530","Stablized at 961","Midpoint of 791","Ends at 743")) -JOB_PLOT <- ggplot(EMPLOY_NUM %>% filter(Category!="Total"),aes(x=Year,y=Employment))+geom_area(position = "stack",aes(fill=Category,group=Category))+theme_bw()+scale_x_continuous(breaks=c(2028,seq(2025,2060,by=5)))+scale_fill_manual(values=COLORS)+geom_line(data=EMPLOY_NUM %>% filter(Category=="Total"),size=1)+geom_text(data=df,aes(label = text), vjust = "inward", hjust = "inward")+theme(legend.position = "top") +JOB_PLOT <- ggplot(EMPLOY_NUM %>% filter(Category!="Total"),aes(x=Year,y=Employment))+geom_area(position = "stack",aes(fill=Category,group=Category))+theme_bw()+scale_x_continuous(breaks=c(2029,seq(2025,2060,by=2)))+scale_fill_manual(values=COLORS)+geom_line(data=EMPLOY_NUM %>% filter(Category=="Total"),size=1)+geom_text(data=df,aes(label = text), vjust = "inward", hjust = "inward")+theme(legend.position = "top")+scale_y_continuous(labels = scales::comma,breaks=seq(0,3000,by=250)) - png(paste0(OUTPUT_DIR,"Job_plot.png" ) , units = "in", width = 10, height = 8, res = 600) +JOB_PLOT + + png(paste0(OUTPUT_DIR,"Job_plot.png" ) , units = "in", width = 11, height = 8, res = 600) JOB_PLOT dev.off() #JOB_PLOT @@ -58,10 +59,8 @@ INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Administrative and sup 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 <- ifelse(INDUSTRY_JOBS$Industry=='Repair and maintenance',"Maintenance",INDUSTRY_JOBS$Industry) +INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Utilities',"Energy Production",INDUSTRY_JOBS$Industry) @@ -79,6 +78,21 @@ png(paste0(OUTPUT_DIR,"Job_Dist_Plot.png"), units = "in", width = 22, height = 1 dev.off() -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") +JOB_FACET <- ggplot(INDUSTRY_JOBS %>% filter(Year %in% c(2032,2033,2045,2060)),aes(x=factor(Year),y=Jobs,fill=factor(Year)))+geom_bar(stat='identity',width=0.99)+facet_wrap(.~Industry)+theme_bw()+xlab("Year")+theme(text=element_text(size=16),legend.position="top",palette.colour.discrete=c("darkslategray1","darkslategray3","darkorchid1","darkorchid3" ))+scale_fill_discrete(name = "Year") +scale_y_continuous(labels = scales::comma,breaks=seq(0,1000,by=100)) +JOB_FACET + +png(paste0(OUTPUT_DIR,"Job_Facet_Plot.png"), units = "in", width = 11, height = 11, res = 600) + JOB_FACET +dev.off() + +##################GDP +GDP <- read_csv(paste0(DATA_DIR,'Gross Domestic Product - By Component - GDP Components.csv'),skip=5)%>% select(-Units) %>% pivot_longer(c(-Category),names_to="Year") %>% mutate(value=parse_number(value)/1000,Year=parse_number(Year)) %>% filter(Year>=2029) +GDP <- GDP %>% filter(Category %in% c('Gross Domestic Product (GDP)','Consumption','Investment','Change in Private Inventories','Net Trade','Government Spending','Exogenous Final Demand')) +GDP_TOTAL <- GDP %>% filter(Category=='Gross Domestic Product (GDP)') %>% select(-Category) %>% rename(GDP=value) +GDP <- GDP %>% filter(Category!='Gross Domestic Product (GDP)') +GDP_PLOT <- ggplot(GDP_TOTAL ,aes(x=Year,y=GDP))+geom_line(linewidth=1,color='slateblue')+theme_bw()+theme(text=element_text(size=16),legend.position="top")+ylab("Wyoming GDP (Million USD)")+scale_x_continuous(breaks=c(seq(2030,2060,by=2)))+scale_y_continuous(breaks=seq(0,500,by=25)) + +png(paste0(OUTPUT_DIR,"GDP_Plot.png"), units = "in", width = 11, height = 8, res = 600) + GDP_PLOT +dev.off()