R/Graphics.R

#################################################################Emisisons Projections Graphs############################################################# 
Set_Sector <- "Energy"
Set_Source <-"Coal"

#Historical and Projected Emissions- COAL  
#group by how we want to see data
energy_by_source <- filter(data_annex_sep2019, year %in% c("1990","2000","2015","2030", "2050"), sector == Set_Sector) %>%
  group_by(year, country, source)%>%
  summarize(value =sum(value, na.rm = TRUE))%>%
  ungroup()

char.year <- as.character(data_annex_sep2019$year)
ggplot(energy_by_source, aes(x = year, y = value, fill = source))+
  geom_col()+
  scale_x_continuous(name = "Year", breaks=c(1990, 2000, 2015, 2030, 2050))+
  scale_y_continuous(name= "MMT CO2 Eq.")+
  theme(panel.background = element_blank(), axis.line = element_line(color = "black"), panel.grid.major = element_blank())

  
ggsave(path="Output/Coal", filename = "Historical_Projected.pdf")

#2030 Emissions by Gas and Subsource 
Source_2030 <- filter(Coal, year == "2030")%>%
  group_by(value, gas, subsource, source )%>%
  summarize(total =sum(value, na.rm =TRUE))%>%
  mutate(percent = (value/total)*100)

ggplot(Source_2030, aes(x = gas , y= value , fill= gas))+
  geom_col(position = "fill", stat = "identity")+
  theme(panel.background = element_blank(), axis.line = element_line(color = "black"), panel.grid.major = element_blank())
ggsave(path="Output/Coal", filename = "2030_Gas.pdf")

#this needs work - not stacking - how to get stack and fill?
ggplot(Source_2030, aes(x=source, y=value , fill = subsource))+
  geom_col(position = "stack",stat = "identity")+
  theme(panel.background = element_blank(), axis.line = element_line(color = "black"), panel.grid.major = element_blank())
ggsave(path="Output/Coal", filename = "2030_Subsource.pdf")

#Projected Emissions   
Emissions <- group_by(Set_Source, year)
  ggplot(Set_Source, aes( x = year, y = value))+
  geom_col()
  geom_text(aes(label=value), na.rm = TRUE,  position=position_dodge(width=0.2))+
    theme(panel.background = element_blank(), axis.line = element_line(color = "black"), panel.grid.major = element_blank())
  ggsave(path="Output/Coal", filename = "Projected_Emissions.pdf")
  

#Top Emitting Countries 
  coal_map<-map_data(maps::world2()) 
  #identify top emitters to color map 
  top_emitters<- filter(Coal, year == "2018")%>%
  group_by(year, country)%>%
  summarize(value = sum(value , na.rm = TRUE)) %>%
  top_n(value, n=5)
    
#create map   
  world<-ne_countries(scale = "medium", returnclass = "sf")
  class(world)
  location <- mutate_geocode(top_emitters, country)
  ggplot(data = world) +
    geom_sf()+
    geom_point(data = location, aes(x=lon, y= lat, fill = country, size = value), color = "red")+
    theme(panel.background = element_blank(), axis.line = element_line(color = "black"), panel.grid.major = element_blank())
  
    ggsave(path="Output/Coal", filename = "Top_Emitters_Map.pdf")


################################MAC GRAPHICS######################################3
    
set_sector_MAC <-
set_source_MAC <- "NGO_MAC"
  
##Emission Reduction Potential 2030
source_2030_MAC <- filter(NGO_MAC, year == "2030") 

emissions_reductions_potential <- 
  
  ggplot(source_2030_MAC, aes(x= Feasibility)) +
  geom_bar()


##Total Reduction Potential 2020,2030,2050##
emissions_potential_total <-filter(NGO_MAC, year %in% c("2020", "2030", "2050"))

ggplot(emissions_potential_total, aes(x= feasibility, y= cost)+
   geom_col()
   
   
#reduction potential by technology
reduction_by_technology <- filter(NGO_MAC, year =="2030")%>%
  summarize(potential = sum(q, na.rm=TRUE))%>%
  group_by(tech, potential)

ggplot(reduction_by_technology, aes(x=tech, y=q))+
  geom_col()
       
       
MollieCarroll/NonCO2-Figs documentation built on April 19, 2020, 6:05 p.m.