From 3f1181677ffb06f26dd486c3122371efde7c5aad Mon Sep 17 00:00:00 2001
From: Marianna Rottoli <marianna.rottoli@mail.polimi.it>
Date: Thu, 7 May 2020 15:31:38 +0200
Subject: [PATCH] Fixes and imporvements to reporting and EDGE-T dashboard.

---
 scripts/output/comparison/EDGEcomparison.R    |  31 ++-
 .../EDGETransportComparison.Rmd               | 170 ++++++------
 .../notebook_templates/EDGEdashboard.Rmd      | 248 +++++++++++++++---
 .../notebook_templates/helper_dashboard.R     | 224 +++++++++++++++-
 .../EDGETransportReport.Rmd                   |   2 +-
 5 files changed, 544 insertions(+), 131 deletions(-)

diff --git a/scripts/output/comparison/EDGEcomparison.R b/scripts/output/comparison/EDGEcomparison.R
index 43c7df0..af5f718 100644
--- a/scripts/output/comparison/EDGEcomparison.R
+++ b/scripts/output/comparison/EDGEcomparison.R
@@ -38,6 +38,7 @@ fleet_all = NULL
 EJroad_all = NULL
 EJmode_all = NULL
 ESmodecap_all = NULL
+ESmodeabs_all = NULL
 CO2km_int_newsales_all = NULL
 EJfuels_all = NULL
 emidem_all = NULL
@@ -159,7 +160,7 @@ EJmodeFun = function(demandEJ){
 }
 
 
-ESmodecapFun = function(demandkm, POP){
+ESmodeFun = function(demandkm, POP){
   ## REMIND-EDGE results
   demandkm <- demandkm[,c("sector","subsector_L3","subsector_L2",
                             "subsector_L1","vehicle_type","technology", "iso","year","demand_F")]
@@ -201,6 +202,12 @@ ESmodecapFun = function(demandkm, POP){
   demandkm = merge(demandkm, REMIND2ISO_MAPPING, by = "iso")
   demandkm = demandkm[, .(demand_F = sum(demand_F)), by = c("region", "year", "vehicle_type_plot", "aggr_mode", "mode")]
   
+  ## save separately the total demand
+  demandkm_abs = copy(demandkm)
+  demandkm_abs = demandkm_abs[year >= 2015 & year <= 2100]
+  demandkm_abs[, demand_F := demand_F/    ## in million km
+                             1e6]         ## in trillion km
+  ## calculate per capita demand
   demandkm = merge(demandkm, POP, all.x = TRUE, by =c("year", "region"))
   
   ## calculate per capita values
@@ -210,7 +217,7 @@ ESmodecapFun = function(demandkm, POP){
   
   demandkm = demandkm[year >= 2015 & year <= 2100]
   
-  return(demandkm)
+  return(list(demandkm = demandkm, demandkm_abs = demandkm_abs))
   
 }
 
@@ -355,7 +362,9 @@ for (outputdir in outputdirs) {
   ## calculate FE demand by mode
   EJmode = EJmodeFun(demandEJ)
   ## calculate ES demand per capita
-  ESmodecap = ESmodecapFun(demandkm, POP)
+  ESmode = ESmodeFun(demandkm, POP)
+  ESmodecap = ESmode[["demandkm"]]
+  ESmodeabs = ESmode[["demandkm_abs"]]
   ## calculate average emissions intensity from the LDVs fleet
   CO2km_int_newsales = CO2km_int_newsales_Fun(shares_LDV, mj_km_data, sharesVS1, FEliq_source$FEliq_sourceISO, gdp)
   ## calculate FE for all transport sectors by fuel, dividng Oil into Biofuels and Synfuels
@@ -369,6 +378,7 @@ for (outputdir in outputdirs) {
   EJroad[, scenario := as.character(unique(miffile$scenario))]
   EJmode[, scenario := as.character(unique(miffile$scenario))]
   ESmodecap[, scenario := as.character(unique(miffile$scenario))]
+  ESmodeabs[, scenario := as.character(unique(miffile$scenario))]
   CO2km_int_newsales[, scenario := as.character(unique(miffile$scenario))]
   EJfuels[, scenario := as.character(unique(miffile$scenario))]
   emidem[, scenario := as.character(unique(miffile$scenario))]
@@ -379,6 +389,7 @@ for (outputdir in outputdirs) {
   EJroad_all = rbind(EJroad_all, EJroad)
   EJmode_all = rbind(EJmode_all, EJmode)
   ESmodecap_all = rbind(ESmodecap_all, ESmodecap)
+  ESmodeabs_all = rbind(ESmodeabs_all, ESmodeabs)
   CO2km_int_newsales_all = rbind(CO2km_int_newsales_all, CO2km_int_newsales)
   EJfuels_all = rbind(EJfuels_all, EJfuels)
   emidem_all = rbind(emidem_all, emidem)
@@ -394,18 +405,20 @@ saveRDS(salescomp_all, paste0(outdir, "/salescomp_all.RDS"))
 saveRDS(fleet_all, paste0(outdir, "/fleet_all.RDS"))
 saveRDS(EJroad_all, paste0(outdir, "/EJroad_all.RDS"))
 saveRDS(ESmodecap_all, paste0(outdir, "/ESmodecap_all.RDS"))
+saveRDS(ESmodeabs_all, paste0(outdir, "/ESmodeabs_all.RDS"))
 saveRDS(CO2km_int_newsales_all, paste0(outdir, "/CO2km_int_newsales_all.RDS"))
 saveRDS(EJfuels_all, paste0(outdir, "/EJfuels_all.RDS"))
 saveRDS(emidem_all, paste0(outdir, "/emidem_all.RDS"))
 file.copy(file.path("./scripts/output/comparison/notebook_templates", md_template), outdir)
 rmarkdown::render(path(outdir, md_template), output_format="pdf_document")
 
-## if it's a 4 scenarios comparison across ConvCase, SynSurge, ElecEra, and HydrHype. run the dashboard
-if (length(outputdirs) == 4 &
-    isTRUE(any(grepl("SynSurge", outputdirs))) &
-    isTRUE(any(grepl("ConvCase", outputdirs))) &
-    isTRUE(any(grepl("ElecEra", outputdirs))) &
-    isTRUE(any(grepl("HydrHype", outputdirs))) ){
+## if it's a 5 scenarios comparison across ConvCase, SynSurge, ElecEra, and HydrHype (with an extra baseline for ConvCase and 4 budgets Budg1100). run the dashboard
+if (length(outputdirs) == 5 &
+    isTRUE(any(grepl("Budg1100_SynSurge", outputdirs))) &
+    isTRUE(any(grepl("Budg1100_ConvCase", outputdirs))) &
+    isTRUE(any(grepl("Budg1100_ElecEra", outputdirs))) &
+    isTRUE(any(grepl("Budg1100_HydrHype", outputdirs))) &
+    isTRUE(any(grepl("Base_ConvCase", outputdirs)))){
  file.copy(file.path("./scripts/output/comparison/notebook_templates/helper_dashboard.R"), outdir)
  file.copy(file.path("./scripts/output/comparison/notebook_templates", dash_template), outdir)
  rmarkdown::render(path(outdir, dash_template))
diff --git a/scripts/output/comparison/notebook_templates/EDGETransportComparison.Rmd b/scripts/output/comparison/notebook_templates/EDGETransportComparison.Rmd
index 340f35c..ee06d9e 100644
--- a/scripts/output/comparison/notebook_templates/EDGETransportComparison.Rmd
+++ b/scripts/output/comparison/notebook_templates/EDGETransportComparison.Rmd
@@ -7,6 +7,10 @@ output:
 classoption: landscape
 ---
 
+```{r setup, include=FALSE}
+knitr::opts_chunk$set(dev = 'pdf')
+```
+
 ```{r, echo=FALSE, message=FALSE, warning=FALSE}
 require(ggplot2)
 require(moinput)
@@ -119,7 +123,7 @@ legend_ord = c(legend_ord_modes, legend_ord_fuels, legend_ord_costs)
 
 ```
 
-```{r, echo=FALSE, message=FALSE, warning=FALSE}
+```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12}
 ## Vintages
 vintcomparisonpf = function(dt){
   dt = dt[year %in% c(2015, 2050, 2100)]
@@ -133,11 +137,13 @@ vintcomparisonpf = function(dt){
     guides(fill = guide_legend(reverse=TRUE))+
     theme_minimal()+
     facet_grid(year~region)+
-    theme(axis.text.x = element_text(angle = 90, size=8, vjust=0.5, hjust=1),
-          title = element_text(size=8),
+    theme(axis.text.x = element_text(angle = 90, size=14, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size=14),
+          axis.title.y = element_text(size=14),
+          title = element_text(size=14),
           axis.line = element_line(size = 0.5, colour = "grey"),
-          # legend.text = element_text(size=8),
-          strip.text = element_text(size=8),
+          legend.text = element_text(size=14),
+          strip.text = element_text(size=14),
           strip.background = element_rect(color = "grey"))+
     scale_alpha_discrete(breaks = c(1,0), name = "Status", labels = c("Vintages","New additions")) +
     guides(linetype=FALSE,
@@ -154,7 +160,7 @@ vintcomparisonpf(fleet_all)
 ```
 
 
-```{r, echo=FALSE, message=FALSE, warning=FALSE}
+```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12}
 salescompf = function(dt){
 
   plot = ggplot()+
@@ -164,14 +170,14 @@ salescompf = function(dt){
     scale_fill_manual("Technology", values = cols)+
     expand_limits(y = c(0,1))+
     scale_x_continuous(breaks = c(2015,2030,2050, 2100))+
-    theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1, size = 8),
-          axis.text.y = element_text(size=8),
+    theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1, size = 14),
+          axis.text.y = element_text(size = 14),
           axis.line = element_line(size = 0.5, colour = "grey"),
-          axis.title = element_text(size = 8),
-          title = element_text(size = 8),
-          # legend.text = element_text(8),
-          # legend.title = element_text(size = 8),
-          strip.text = element_text(size=8),
+          axis.title = element_text(size = 14),
+          title = element_text(size = 14),
+          legend.text = element_text(size = 14),
+          legend.title = element_text(size = 14),
+          strip.text = element_text(size = 14),
           strip.background = element_rect(color = "grey"))+
     labs(x = "", y = "[%]", title = "Market share of new LDV sales")
   return(plot)
@@ -181,7 +187,7 @@ salescompf(salescomp_all)
 
 ```
 
-```{r, echo=FALSE, message=FALSE, warning=FALSE}
+```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12}
 EJroadpf = function(dt){
   dt[, technology := factor(technology, levels = legend_ord)]
   dt = dt[year >= 2020]
@@ -193,14 +199,14 @@ EJroadpf = function(dt){
     scale_fill_manual("Technology", values = cols, breaks=legend_ord)+
     expand_limits(y = c(0,1))+
     scale_x_continuous(breaks = c(2020, 2030,2050, 2100))+
-    theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1),
-          axis.text.y = element_text(size = 8),
-          axis.title = element_text(size = 8),
+    theme(axis.text.x = element_text(angle = 90, size = 14, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 14),
+          axis.title = element_text(size = 14),
           axis.line = element_line(size = 0.5, colour = "grey"),
-          title = element_text(size = 8),
-          # legend.text = element_text(size =8),
-          # legend.title = element_text(size = 8),
-          strip.text = element_text(size=8),
+          title = element_text(size = 14),
+          legend.text = element_text(size = 14),
+          legend.title = element_text(size = 14),
+          strip.text = element_text(size = 14),
           strip.background = element_rect(color = "grey"))
 
 
@@ -212,14 +218,14 @@ EJroadpf = function(dt){
     scale_fill_manual("Technology", values = cols, breaks=legend_ord)+
     expand_limits(y = c(0,1))+
     scale_x_continuous(breaks = c(2020, 2030,2050, 2100))+
-    theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1),
-          axis.text.y = element_text(size = 8),
-          axis.title = element_text(size = 8),
+    theme(axis.text.x = element_text(angle = 90, size = 14, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 14),
+          axis.title = element_text(size = 14),
           axis.line = element_line(size = 0.5, colour = "grey"),
-          title = element_text(size = 8),
-          # legend.text = element_text(size =8),
-          # legend.title = element_text(size = 8),
-          strip.text = element_text(size=8),
+          title = element_text(size = 14),
+          legend.text = element_text(size = 14),
+          legend.title = element_text(size = 14),
+          strip.text = element_text(size = 14),
           strip.background = element_rect(color = "grey"))
 
 
@@ -231,14 +237,14 @@ EJroadpf = function(dt){
     scale_fill_manual("Technology", values = cols, breaks=legend_ord)+
     expand_limits(y = c(0,1))+
     scale_x_continuous(breaks = c(2020, 2030,2050, 2100))+
-    theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1),
-          axis.text.y = element_text(size = 8),
-          axis.title = element_text(size = 8),
+    theme(axis.text.x = element_text(angle = 90, size = 14, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 14),
+          axis.title = element_text(size = 14),
           axis.line = element_line(size = 0.5, colour = "grey"),
-          title = element_text(size = 8),
-          # legend.text = element_text(size =8),
-          # legend.title = element_text(size = 8),
-          strip.text = element_text(size=8),
+          title = element_text(size = 14),
+          legend.text = element_text(size = 14),
+          legend.title = element_text(size = 14),
+          strip.text = element_text(size = 14),
           strip.background = element_rect(color = "grey"))
 
   return(plotlist = list(plotLDV = plotLDV, plotBus = plotBus, plotTrucks = plotTrucks))
@@ -248,7 +254,7 @@ EJroadpf(EJroad_all)
 
 ```
 
-```{r, echo=FALSE, message=FALSE, warning=FALSE}
+```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12}
 EJmodepf = function(dt){
   dt = dt[year >= 2020]
   plot = ggplot()+
@@ -259,13 +265,13 @@ EJmodepf = function(dt){
     scale_fill_manual("Vehicle Type",values = cols, breaks=legend_ord)+
     expand_limits(y = c(0,1))+
     scale_x_continuous(breaks = c(2020,2030,2050, 2100))+
-    theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1),
-          axis.text.y = element_text(size=8),
-          axis.title = element_text(size = 8),
-          title = element_text(size = 8),
-          # legend.text = element_text(size = 8),
-          # legend.title = element_text(size =8),
-          strip.text = element_text(size=8),
+    theme(axis.text.x = element_text(angle = 90, size = 14, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 14),
+          axis.title = element_text(size = 14),
+          title = element_text(size = 14),
+          legend.text = element_text(size = 14),
+          legend.title = element_text(size = 14),
+          strip.text = element_text(size = 14),
           axis.line = element_line(size = 0.5, colour = "grey"),
           strip.background = element_rect(color = "grey"))
   return(plot)
@@ -276,7 +282,7 @@ EJmodepf(EJmode_all)
 ```
 
 
-```{r, echo=FALSE, message=FALSE, warning=FALSE}
+```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12}
 ESmodecappf = function(dt){
   dt[, vehicle_type_plot := factor(vehicle_type_plot, levels = legend_ord)]
   plot_frgt = ggplot()+
@@ -287,13 +293,13 @@ ESmodecappf = function(dt){
     scale_fill_manual("Vehicle Type",values = cols, breaks=legend_ord)+
     expand_limits(y = c(0,1))+
     scale_x_continuous(breaks = c(2020,2030,2050, 2100))+
-    theme(axis.text.x = element_text(angle = 90,  size = 8, vjust=0.5, hjust=1),
-          axis.text.y = element_text(size = 8),
-          axis.title = element_text(size = 8),
-          title = element_text(size = 8),
-          legend.text = element_text(size = 8),
-          legend.title = element_text(size = 8),
-          strip.text = element_text(size = 8),
+    theme(axis.text.x = element_text(angle = 90,  size = 14, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 14),
+          axis.title = element_text(size = 14),
+          title = element_text(size = 14),
+          legend.text = element_text(size = 14),
+          legend.title = element_text(size = 14),
+          strip.text = element_text(size = 14),
           strip.background = element_rect(color = "grey"),
           axis.line = element_line(size = 0.5, colour = "grey"))
 
@@ -306,13 +312,13 @@ ESmodecappf = function(dt){
     scale_fill_manual("Vehicle Type",values = cols, breaks=legend_ord)+
     expand_limits(y = c(0,1))+
     scale_x_continuous(breaks = c(2020,2030,2050, 2100))+
-    theme(axis.text.x = element_text(angle = 90,  size = 8, vjust=0.5, hjust=1),
-          axis.text.y = element_text(size = 8),
-          axis.title = element_text(size = 8),
-          title = element_text(size = 8),
-          legend.text = element_text(size = 8),
-          legend.title = element_text(size = 8),
-          strip.text = element_text(size = 8),
+    theme(axis.text.x = element_text(angle = 90,  size = 14, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 14),
+          axis.title = element_text(size = 14),
+          title = element_text(size = 14),
+          legend.text = element_text(size = 14),
+          legend.title = element_text(size = 14),
+          strip.text = element_text(size = 14),
           strip.background = element_rect(color = "grey"),
           axis.line = element_line(size = 0.5, colour = "grey"))
 
@@ -326,7 +332,7 @@ ESmodecappf(ESmodecap_all)
 ```
 
 
-```{r, echo=FALSE, message=FALSE, warning=FALSE}
+```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12}
 CO2km_int_newsalespf = function(dt){
   dt = dt[!is.na(gCO2_km_ave)]
   plot = ggplot()+
@@ -336,13 +342,13 @@ CO2km_int_newsalespf = function(dt){
     scale_x_continuous(breaks = c(2020, 2030, 2050, 2100))+
     theme_minimal()+
     facet_grid(~region)+
-    theme(axis.text.x = element_text(angle = 90,  size = 8, vjust=0.5, hjust=1),
-          axis.text.y = element_text(size = 8),
-          axis.title = element_text(size = 8),
-          title = element_text(size = 8),
-          legend.text = element_text(size = 8),
-          legend.title = element_text(size = 8),
-          strip.text = element_text(size = 8),
+    theme(axis.text.x = element_text(angle = 90,  size = 14, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 14),
+          axis.title = element_text(size = 14),
+          title = element_text(size = 14),
+          legend.text = element_text(size = 14),
+          legend.title = element_text(size = 14),
+          strip.text = element_text(size = 14),
           strip.background = element_rect(color = "grey"),
           axis.line = element_line(size = 0.5, colour = "grey"))+
     guides(linetype = FALSE)
@@ -353,7 +359,7 @@ CO2km_int_newsalespf(CO2km_int_newsales_all)
 ```
 
 
-```{r, echo=FALSE, message=FALSE, warning=FALSE}
+```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12}
 ## LDV by fuel
 EJfuels_pf = function(dt){
   dt = dt[year >= 2020]
@@ -365,13 +371,13 @@ EJfuels_pf = function(dt){
     scale_fill_manual("Technology",values = cols, breaks=legend_ord)+
     expand_limits(y = c(0,1))+
     scale_x_continuous(breaks = c(2020, 2030,2050, 2100))+
-    theme(axis.text.x = element_text(angle = 90,  size = 8, vjust=0.5, hjust=1),
-          axis.text.y = element_text(size = 8),
-          axis.title = element_text(size = 8),
-          title = element_text(size = 8),
-          legend.text = element_text(size = 8),
-          legend.title = element_text(size = 8),
-          strip.text = element_text(size = 8),
+    theme(axis.text.x = element_text(angle = 90,  size = 14, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 14),
+          axis.title = element_text(size = 14),
+          title = element_text(size = 14),
+          legend.text = element_text(size = 14),
+          legend.title = element_text(size = 14),
+          strip.text = element_text(size = 14),
           strip.background = element_rect(color = "grey"),
           axis.line = element_line(size = 0.5, colour = "grey"))
   return(plot)
@@ -381,7 +387,7 @@ EJfuels_pf(EJfuels_all)
 ```
 
 
-```{r, echo=FALSE, message=FALSE, warning=FALSE}
+```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12}
 emidem_pf = function(dt){
  dt[, scenario := as.character(scenario)]
   plot = ggplot()+
@@ -389,13 +395,13 @@ emidem_pf = function(dt){
     labs(x = "", y = "CO2 emissions [Mt/CO2]", title = "Emissions from transport demand")+
     theme_minimal()+
     facet_grid(~region)+
-    theme(axis.text.x = element_text(angle = 90,  size = 8, vjust=0.5, hjust=1),
-          axis.text.y = element_text(size = 8),
-          axis.title = element_text(size = 8),
-          title = element_text(size = 8),
-          legend.text = element_text(size = 8),
-          legend.title = element_text(size = 8),
-          strip.text = element_text(size = 8),
+    theme(axis.text.x = element_text(angle = 90,  size = 14, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 14),
+          axis.title = element_text(size = 14),
+          title = element_text(size = 14),
+          legend.text = element_text(size = 14),
+          legend.title = element_text(size = 14),
+          strip.text = element_text(size = 14),
           strip.background = element_rect(color = "grey"),
           axis.line = element_line(size = 0.5, colour = "grey"))
  
diff --git a/scripts/output/comparison/notebook_templates/EDGEdashboard.Rmd b/scripts/output/comparison/notebook_templates/EDGEdashboard.Rmd
index 045ba6b..f830d9c 100644
--- a/scripts/output/comparison/notebook_templates/EDGEdashboard.Rmd
+++ b/scripts/output/comparison/notebook_templates/EDGEdashboard.Rmd
@@ -1,5 +1,5 @@
 ---
-title: "Transport decarbonization dashboard"
+title: "Transport decarbonization pathways in Europe"
 author: ""
 output: 
   flexdashboard::flex_dashboard:
@@ -38,8 +38,8 @@ legend=plotlist$legend
   #data frame with help tooltips
 
   helpTooltip_df <- data.frame(
-    title=c("Per capita Passenger Transport Energy Services Demand", "Per capita Freight Transport Energy Services Demand", "Sales composition", "Final energy LDVs by fuel","Transport Final Energy Demand", "Fleet composition"),
-    placement=c("right", "left", "right", "left", "left", "left"))
+    title=c("Per capita Passenger Transport Energy Services Demand", "Total Passenger Transport Energy Services Demand", "Sales composition", "Final energy LDVs by fuel","Transport Final Energy Demand", "Fleet composition", "Fleet composition comparison", "Emission intensity, new sales comparison", "Comparison of final energy demand"),
+    placement=c("right", "left", "right", "left", "left", "left", "right", "left", "left"))
 
 
 helpTooltip = function(tooltipdf){
@@ -98,7 +98,8 @@ Overview {data-icon="glyphicon glyphicon-scale"}
 Side Navigation {.sidebar data-width=60}
 -------------------------------------
 
-[](#overview){class="glyphicon glyphicon-oil sidebar-button selected"}
+[](#overview){class="fas fa-thermometer-three-quarters sidebar-button selected"}
+[](#overview-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"}
 [](#overview-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"}
 [](#overview-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"}
 [](#overview-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"}
@@ -106,6 +107,69 @@ Side Navigation {.sidebar data-width=60}
 Row {data-height=300}
 -----------------------------------------------------------------------
 
+### Transport scenario {data-width=100}
+```{r}
+valueBox("Conventional Case NoTax", icon = "fa-thermometer-three-quarters")
+```
+
+
+### Emissions {data-width=100}
+```{r}
+valueBox(plotlist$`ConvCase NoTax`$emiscen, icon = "fa-cloud")
+```
+
+
+### Scenario description {data-width=200}
+
+Absence of policies oriented to promote alternative vehicles. Internal combustion engines lead the market.
+
+<!-- Dividing the page in two columns-->
+Row {data-heigth=500}
+-----------------------------------------------------------------------
+
+### Per capita Passenger Transport Energy Services Demand
+```{r}
+plotlist$`ConvCase NoTax`$plot$ESmodecap_pass
+```
+
+### Total Passenger Transport Energy Services Demand
+```{r}
+plotlist$`ConvCase NoTax`$plot$ESmodeabs
+```
+
+
+Row {data-heigth=500}
+-----------------------------------------------------------------------
+
+### Transport Final Energy Demand
+
+```{r}
+plotlist$`ConvCase NoTax`$plot$EJfuels
+```
+
+### Emissions transport demand
+
+```{r}
+plotlist$`ConvCase NoTax`$plot$emidem
+```
+
+Overview Conv scenario {.hidden data-icon="glyphicon glyphicon-tint"}
+===================================== 
+
+Side Navigation {.sidebar data-width=60}
+-------------------------------------
+
+[](#overview){class="fas fa-thermometer-three-quarters sidebar-button"}
+[](#overview-conv-scenario){class="glyphicon glyphicon-oil sidebar-button selected"}
+[](#overview-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"}
+[](#overview-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"}
+[](#overview-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"}
+
+
+<!-- Dividing the page in two rows-->
+Row {data-height=300}
+-----------------------------------------------------------------------
+
 ### Transport scenario {data-width=100}
 ```{r}
 valueBox("Conventional Case", icon = "glyphicon-oil")
@@ -120,7 +184,7 @@ valueBox(plotlist$ConvCase$emiscen, icon = "fa-cloud")
 
 ### Scenario description {data-width=200}
 
-Conventional patterns.
+Absence of policies oriented to promote alternative vehicles. Internal combustion engines lead the market.
 
 <!-- Dividing the page in two columns-->
 Row {data-heigth=500}
@@ -131,9 +195,9 @@ Row {data-heigth=500}
 plotlist$ConvCase$plot$ESmodecap_pass
 ```
 
-### Per capita Freight Transport Energy Services Demand
+### Total Passenger Transport Energy Services Demand
 ```{r}
-plotlist$ConvCase$plot$ESmodecap_frgt
+plotlist$ConvCase$plot$ESmodeabs
 ```
 
 
@@ -152,13 +216,15 @@ plotlist$ConvCase$plot$EJfuels
 plotlist$ConvCase$plot$emidem
 ```
 
+
 Overview FCEV scenario {.hidden data-icon="glyphicon glyphicon-tint"}
 ===================================== 
 
 Side Navigation {.sidebar data-width=60}
 -------------------------------------
 
-[](#overview){class="glyphicon glyphicon-oil sidebar-button"}
+[](#overview){class="fas fa-thermometer-three-quarters sidebar-button"}
+[](#overview-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"}
 [](#overview-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button selected"}
 [](#overview-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"}
 [](#overview-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"}
@@ -182,7 +248,7 @@ valueBox(plotlist$HydrHype$emiscen, icon = "fa-cloud")
 
 ### Scenario description {data-width=200}
 
-Increased preference for hydrogen vehicles.
+Hydrogen vehicles gain an important share of the mix thanks to policies oriented at promoting them.
 
 <!-- Dividing the page in two columns-->
 Row {data-heigth=500}
@@ -193,9 +259,9 @@ Row {data-heigth=500}
 plotlist$HydrHype$plot$ESmodecap_pass
 ```
 
-### Per capita Freight Transport Energy Services Demand
+### Total Passenger Transport Energy Services Demand
 ```{r}
-plotlist$HydrHype$plot$ESmodecap_frgt
+plotlist$HydrHype$plot$ESmodeabs
 ```
 
 
@@ -221,7 +287,8 @@ Overview BEV scenario { .hidden data-icon="glyphicon glyphicon-flash"}
 Side Navigation {.sidebar data-width=60}
 -------------------------------------
 
-[](#overview){class="glyphicon glyphicon-oil sidebar-button"}
+[](#overview){class="fas fa-thermometer-three-quarters sidebar-button"}
+[](#overview-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"}
 [](#overview-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"}
 [](#overview-bev-scenario){class="glyphicon glyphicon-flash sidebar-button selected"}
 [](#overview-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"}
@@ -243,7 +310,7 @@ valueBox(plotlist$ElecEra$emiscen, icon = "fa-cloud")
 
 ### Scenario description {data-width=200}
 
-Increased preference for battery electric vehicles.
+Electric vehicles gain an important share of the mix thanks to policies oriented at promoting them.
 
 
 <!-- Dividing the page in two columns-->
@@ -255,9 +322,9 @@ Row {data-heigth=500}
 plotlist$ElecEra$plot$ESmodecap_pass
 ```
 
-### Per capita Freight Transport Energy Services Demand
+### Total Passenger Transport Energy Services Demand
 ```{r}
-plotlist$ElecEra$plot$ESmodecap_frgt
+plotlist$ElecEra$plot$ESmodeabs
 ```
 
 
@@ -282,7 +349,8 @@ Overview Synfuel scenario {.hidden data-icon="glyphicon glyphicon-random"}
 Side Navigation {.sidebar data-width=60}
 -------------------------------------
 
-[](#overview){class="glyphicon glyphicon-oil sidebar-button"}
+[](#overview){class="fas fa-thermometer-three-quarters sidebar-button"}
+[](#overview-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"}
 [](#overview-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"}
 [](#overview-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"}
 [](#overview-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button selected"}
@@ -304,8 +372,7 @@ valueBox(plotlist$SynSurge$emiscen, icon = "fa-cloud")
 
 ### Scenario description {data-width=200}
 
-Increased preference for synthetic fuels.
-
+Synthetic fuels gain great importance in the liquid fuels production. Absence of policies oriented to promote alternative vehicles. Internal combustion engines lead the market.
 
 <!-- Dividing the page in two columns-->
 Row {data-heigth=500}
@@ -316,9 +383,9 @@ Row {data-heigth=500}
 plotlist$SynSurge$plot$ESmodecap_pass
 ```
 
-### Per capita Freight Transport Energy Services Demand
+### Total Passenger Transport Energy Services Demand
 ```{r}
-plotlist$SynSurge$plot$ESmodecap_frgt
+plotlist$SynSurge$plot$ESmodeabs
 ```
 
 
@@ -344,7 +411,8 @@ LDVs {data-icon="fa-car"}
 Side Navigation {.sidebar data-width=60}
 -------------------------------------
 
-[](#ldvs){class="glyphicon glyphicon-oil sidebar-button selected"}
+[](#ldvs){class="fas fa-thermometer-three-quarters sidebar-button selected"}
+[](#ldvs-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"}
 [](#ldvs-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"}
 [](#ldvs-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"}
 [](#ldvs-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"}
@@ -355,22 +423,85 @@ Row {data-height=300}
 
 ### Transport scenario {data-width=100}
 ```{r}
-valueBox("Conventional Case", icon = "glyphicon-oil")
+valueBox("Conventional Case NoTax", icon = "fa-thermometer-three-quarters")
 ```
 
 
 ### Emissions {data-width=100}
 ```{r}
-valueBox(plotlist$ConvCase$emiscen, icon = "fa-cloud")
+valueBox(plotlist$`ConvCase NoTax`$emiscen, icon = "fa-cloud")
 ```
 
 
 ### Scenario description {data-width=200}
 
-Conventional patterns.
+Absence of policies oriented to promote alternative vehicles. Internal combustion engines lead the market.
 
+<!-- Dividing the page in two rows-->
+Row {data-height= 450}
+-----------------------------------------------------------------------
+
+### Sales composition {data-width=250}
+```{r}
+plotlist$`ConvCase NoTax`$plot$salescomp
+```
+
+
+### CO~2~ intensity of new sales {data-width=250}
+
+```{r}
+plotlist$`ConvCase NoTax`$plot$CO2km_int_newsales
+```
+
+
+Row {data-height= 450}
+-----------------------------------------------------------------------
+
+### Final energy LDVs by fuel
+```{r}
+plotlist$`ConvCase NoTax`$plot$EJLDV
+```
+
+
+### Fleet composition
+```{r}
+plotlist$`ConvCase NoTax`$plot$vintcomp
+```
+
+LDVs Conv scenario { .hidden data-icon="glyphicon glyphicon-flash"}
+===================================== 
+
+
+Side Navigation {.sidebar data-width=60}
+-------------------------------------
+
+[](#ldvs){class="fas fa-thermometer-three-quarters sidebar-button"}
+[](#ldvs-conv-scenario){class="glyphicon glyphicon-oil sidebar-button selected"}
+[](#ldvs-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"}
+[](#ldvs-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"}
+[](#ldvs-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"}
 
 
+<!-- Dividing the page in two rows-->
+Row {data-height=300}
+-----------------------------------------------------------------------
+
+### Transport scenario {data-width=100}
+```{r}
+valueBox("Conventional Case", icon = "glyphicon-oil")
+```
+
+
+### Emissions {data-width=100}
+```{r}
+valueBox(plotlist$ConvCase$emiscen, icon = "fa-cloud")
+```
+
+
+### Scenario description {data-width=200}
+
+Absence of policies oriented to promote alternative vehicles. Internal combustion engines lead the market.
+
 <!-- Dividing the page in two rows-->
 Row {data-height= 450}
 -----------------------------------------------------------------------
@@ -403,14 +534,14 @@ plotlist$ConvCase$plot$vintcomp
 ```
 
 
-
 LDVs FCEV scenario {.hidden data-icon="glyphicon glyphicon-tint"}
 ===================================== 
 
 Side Navigation {.sidebar data-width=60}
 -------------------------------------
 
-[](#ldvs){class="glyphicon glyphicon-oil sidebar-button"}
+[](#ldvs){class="fas fa-thermometer-three-quarters sidebar-button"}
+[](#ldvs-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"}
 [](#ldvs-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button selected"}
 [](#ldvs-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"}
 [](#ldvs-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"}
@@ -434,7 +565,8 @@ valueBox(plotlist$HydrHype$emiscen, icon = "fa-cloud")
 
 ### Scenario description {data-width=200}
 
-Increased preference for hydrogen vehicles.
+Hydrogen vehicles gain an important share of the mix thanks to policies oriented at promoting them.
+
 
 <!-- Dividing the page in two rows-->
 Row {data-height= 450}
@@ -475,7 +607,8 @@ LDVs BEV scenario { .hidden data-icon="glyphicon glyphicon-flash"}
 Side Navigation {.sidebar data-width=60}
 -------------------------------------
 
-[](#ldvs){class="glyphicon glyphicon-oil sidebar-button"}
+[](#ldvs){class="fas fa-thermometer-three-quarters sidebar-button"}
+[](#ldvs-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"}
 [](#ldvs-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"}
 [](#ldvs-bev-scenario){class="glyphicon glyphicon-flash sidebar-button selected"}
 [](#ldvs-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"}
@@ -499,7 +632,7 @@ valueBox(plotlist$ElecEra$emiscen, icon = "fa-cloud")
 
 ### Scenario description {data-width=200}
 
-Increased preference for battery electric vehicles.
+Electric vehicles gain an important share of the mix thanks to policies oriented at promoting them.
 
 
 <!-- Dividing the page in two rows-->
@@ -540,7 +673,8 @@ LDVs Synfuel scenario {.hidden data-icon="glyphicon glyphicon-random"}
 Side Navigation {.sidebar data-width=60}
 -------------------------------------
 
-[](#ldvs){class="glyphicon glyphicon-oil sidebar-button"}
+[](#ldvs){class="fas fa-thermometer-three-quarters sidebar-button"}
+[](#ldvs-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"}
 [](#ldvs-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"}
 [](#ldvs-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"}
 [](#ldvs-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button selected"}
@@ -563,7 +697,7 @@ valueBox(plotlist$SynSurge$emiscen, icon = "fa-cloud")
 
 ### Scenario description {data-width=200}
 
-Increased preference for synthetic fuels.
+Synthetic fuels gain great importance in the liquid fuels production. Absence of policies oriented to promote alternative vehicles. Internal combustion engines lead the market.
 
 
 
@@ -598,6 +732,58 @@ plotlist$SynSurge$plot$EJLDV
 plotlist$SynSurge$plot$vintcomp
 ```
 
+Comparison {data-icon="fa-exchange-alt"}
+=====================================
+Row {data-height=300}
+-----------------------------------------------------------------------
+
+### Fleet composition comparison
+```{r}
+plotlist$comparison$plot$vintscen
+```
+
+### Emission intensity, new sales comparison
+```{r}
+plotlist$comparison$plot$CO2km_intensity_newsales_scen
+```
+Row {data-height=300}
+-----------------------------------------------------------------------
+
+### Comparison of final energy demand
+```{r}
+plotlist$comparison$plot$EJfuels_scen
+```
+
+Assumptions {data-icon="fa-comment"}
+=====================================
+
+### Conventional Case {data-height=200}
+
+* Conventional consumers patterns
+* No policies to promote alternative vehicles
+* Learning rate on BEVs and FCEVs
+* Market-driven behavior of light duty vehicles powertrain choice
+
+### Hydrogen Hype {data-height=200}
+
+* Learning rate on BEVs and FCEVs
+* Optimistic trend of hydrogen refuelling stations
+* Rebates-feebates scheme: 5000 € subsidies starting in 2020 on FCEVs, phasing out by 2035. 1000 € mark-up cost on internal combustion engines
+* Market-driven behavior of light duty vehicles powertrain choice
+* Policy push of FCEVs
+
+### Electric Era {data-height=200}
+
+* Learning rate on BEVs and FCEVs
+* Rebates-feebates scheme: 5000 € subsidies starting in 2020 on BEVs, phasing out by 2035. 1000 € mark-up cost on internal combustion engines
+* Market-driven behavior of light duty vehicles powertrain choice
+
+### Synfuel Surge {data-height=200}
+
+* Conventional consumers patterns
+* Learning rate on BEVs and FCEVs
+* Market-driven behavior of light duty vehicles powertrain choice
+* Synfuels are forced in the liquids mix reaching 10% in 2035
 
 <!-- creating information tooltip -->
 ```{r, results='asis'}
diff --git a/scripts/output/comparison/notebook_templates/helper_dashboard.R b/scripts/output/comparison/notebook_templates/helper_dashboard.R
index 63139e2..be23779 100644
--- a/scripts/output/comparison/notebook_templates/helper_dashboard.R
+++ b/scripts/output/comparison/notebook_templates/helper_dashboard.R
@@ -67,7 +67,9 @@ cols <- c("NG" = "#d11141",
           "Hydrogen_push" = "#00aedb",
           "Conservative_liquids" = "#113245",
           "ConvCase" = "#113245",
-          "ConvCaseWise" = "#d11141")
+          "ConvCaseNoTax" = "#d11141",
+          "ConvCaseWise" = "#d11141",
+          "SynSurge" = "orchid")
 
 legend_ord_modes <- c("Freight Rail", "Truck", "Shipping", "International Shipping", "Domestic Shipping",  "Trucks",
                       "Motorbikes", "Small Cars", "Large Cars", "Van",
@@ -88,6 +90,7 @@ EJroad_all = readRDS("EJroad_all.RDS")
 fleet_all = readRDS("fleet_all.RDS")
 salescomp_all = readRDS("salescomp_all.RDS")
 ESmodecap_all = readRDS("ESmodecap_all.RDS")
+ESmodeabs_all = readRDS("ESmodeabs_all.RDS")
 CO2km_int_newsales_all = readRDS("CO2km_int_newsales_all.RDS")
 EJfuels_all = readRDS("EJfuels_all.RDS")
 emidem_all = readRDS("emidem_all.RDS")
@@ -120,6 +123,7 @@ vintcomparisondash = function(dt, scen){
     guides(linetype=FALSE,
            fill=guide_legend(reverse=FALSE, title="Transport mode"))+
     scale_fill_manual(values = cols)+
+    ylim(0, 650)+
     labs(x = "", y = "")
   
   
@@ -133,6 +137,50 @@ vintcomparisondash = function(dt, scen){
                 vars = vars)
 }
 
+
+vintscen_dash = function(dt){
+  dt[, scenario := ifelse(scenario == "Base_ConvCase", "ConvCaseNoTax", scenario)]
+  dt = dt[year %in% c(2015, 2030, 2050)]
+  dt[, year := as.character(year)]
+  dt = dt[region == region_plot]
+  dt = dt[,.(value = sum(value)), by = c("region", "technology", "year", "scenario")]
+  dt[, scenario := gsub(".*_", "", scenario)]
+  dt[, scenario := factor(scenario, levels = c("ConvCaseNoTax", "ConvCase", "HydrHype", "ElecEra", "SynSurge"))]
+  dt[, details := paste0("Vehicles: ", round(value, 0), " [million]", "<br>", "Technology: ", technology, "<br>", "Region: ", region," <br>", "Year: ", year) ]
+  plot = ggplot()+
+    geom_bar(data = dt,
+             aes(x = scenario, y = value, group = technology, text = details, fill = technology, width=.75), position="stack", stat = "identity", width = 0.5)+
+    guides(fill = guide_legend(reverse=TRUE))+
+    facet_wrap(~year, nrow = 1)+
+    theme_minimal()+
+    theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1, size = 8),
+          axis.text.y = element_text(size=8),
+          axis.line = element_line(size = 0.5, colour = "grey"),
+          axis.title = element_text(size = 8),
+          title = element_text(size = 8),
+          strip.text = element_text(size=8),
+          strip.background = element_rect(color = "grey"),
+          legend.position = "none")+
+    scale_alpha_discrete(breaks = c(1,0), name = "Status", labels = c("Vintages","New additions")) +
+    guides(linetype=FALSE,
+           fill=guide_legend(reverse=FALSE, title="Transport mode"))+
+    scale_fill_manual(values = cols)+
+    ylim(0, 650)+
+    labs(x = "", y = "")
+  
+  
+  plot = ggplotly(plot, tooltip = c("text")) %>%
+    config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE)%>%
+    layout(yaxis=list(title='[million veh]', titlefont = list(size = 10)))
+  
+  vars = as.character(unique(dt$technology))
+  
+  output = list(plot = plot,
+                vars = vars)
+}
+
+
+
 salescomdash = function(dt, scen){
   
   dt = dt[region == region_plot & scenario == scen & year <=2050]
@@ -177,6 +225,7 @@ ESmodecapdash = function(dt, scen){
     theme_minimal()+
     scale_fill_manual("Vehicle Type", values = cols, breaks=legend_ord)+
     expand_limits(y = c(0,1))+
+    ylim(0,32000)+
     scale_x_continuous(breaks = c(2015, 2030, 2050))+
     theme(axis.text.x = element_text(angle = 90,  size = 8, vjust=0.5, hjust=1),
           axis.text.y = element_text(size = 8),
@@ -193,6 +242,7 @@ ESmodecapdash = function(dt, scen){
     theme_minimal()+
     scale_fill_manual("Vehicle Type", values = cols, breaks=legend_ord)+
     expand_limits(y = c(0,1))+
+    ylim(0,64000)+
     scale_x_continuous(breaks = c(2015, 2030, 2050))+
     theme(axis.text.x = element_text(angle = 90,  size = 8, vjust=0.5, hjust=1),
           axis.text.y = element_text(size = 8),
@@ -220,6 +270,43 @@ ESmodecapdash = function(dt, scen){
   
 }
 
+
+
+ESmodeabs_dash = function(dt, scen){
+  dt = dt[region == region_plot & scenario == scen & year <= 2050]
+  dt[, details := paste0("Demand: ", round(demand_F, digits = 1), ifelse(mode == "pass", " [trillion pkm]",  " [trillion tkm]"), "<br>", "Vehicle: ", vehicle_type_plot, "<br>", "Region: ", region," <br>", "Year: ", year) ] 
+  
+  plot_pass = ggplot()+
+    geom_area(data = dt[mode == "pass"], aes(x = year, y = demand_F, group = vehicle_type_plot, fill = vehicle_type_plot, text = details), position= position_stack())+
+    labs(x = "", y = "")+
+    theme_minimal()+
+    scale_fill_manual("Vehicle Type", values = cols, breaks=legend_ord)+
+    expand_limits(y = c(0,1))+
+    ylim(0, 17)+
+    scale_x_continuous(breaks = c(2015, 2030, 2050))+
+    theme(axis.text.x = element_text(angle = 90,  size = 8, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 8),
+          axis.title = element_text(size = 8),
+          title = element_text(size = 8),
+          legend.position = "none",
+          strip.text = element_text(size = 8),
+          strip.background = element_rect(color = "grey"),
+          axis.line = element_line(size = 0.5, colour = "grey"))
+  
+  plot_pass = ggplotly(plot_pass, tooltip = c("text")) %>%
+    config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE) %>%
+    layout(yaxis=list(title='[trillion pkm]', titlefont = list(size = 10)))
+
+  vars_pass = as.character(unique(dt[mode == "pass"]$vehicle_type_plot))
+  
+  output = list(plot = plot_pass,
+                vars = vars_pass)
+  
+  return(output)
+  
+}
+
+
 EJfuels_dash = function(dt, scen){
   dt = dt[region == region_plot & scenario == scen & year >= 2015  & year <= 2050]
   dt[, details := paste0("Demand: ", round(demand_EJ, digits = 0), " [EJ]","<br>", "Technology: ", subtech, "<br>", "Region: ", region," <br>", "Year: ", year) ]
@@ -229,6 +316,7 @@ EJfuels_dash = function(dt, scen){
     theme_minimal()+
     scale_fill_manual("Technology",values = cols, breaks=legend_ord)+
     expand_limits(y = c(0,1))+
+    ylim(0, 25)+
     labs(x = "", y = "")+
     scale_x_continuous(breaks = c(2015, 2030, 2050))+
     theme(axis.text.x = element_text(angle = 90,  size = 8, vjust=0.5, hjust=1),
@@ -252,6 +340,45 @@ EJfuels_dash = function(dt, scen){
   return(output)
 }
 
+EJfuels_scen_dash = function(dt){
+  dt[, scenario := ifelse(scenario == "Base_ConvCase", "ConvCaseNoTax", scenario)]
+  dt = dt[region == region_plot & year %in% c(2015, 2030, 2050)]
+  dt[, details := paste0("Demand: ", round(demand_EJ, digits = 0), " [EJ]","<br>", "Technology: ", subtech, "<br>", "Region: ", region," <br>", "Year: ", year) ]
+  dt[, scenario := gsub(".*_", "", scenario)]
+  dt[, scenario := factor(scenario, levels = c("ConvCaseNoTax", "ConvCase", "HydrHype", "ElecEra", "SynSurge"))]
+  
+  plot = ggplot()+
+    geom_bar(data = dt, aes(x = scenario, y = demand_EJ, group = subtech,
+                            fill = subtech, 
+                            text = details, width=.75), 
+             position="stack", stat = "identity", width = 0.5)+
+    facet_wrap(~year, nrow = 1)+
+    theme_minimal()+
+    scale_fill_manual("Technology",values = cols, breaks=legend_ord)+
+    expand_limits(y = c(0,1))+
+    ylim(0, 25)+
+    labs(x = "", y = "")+
+    theme(axis.text.x = element_text(angle = 90,  size = 8, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 8),
+          axis.title = element_text(size = 8),
+          title = element_text(size = 8),
+          legend.position = "none",
+          strip.text = element_text(size = 8),
+          strip.background = element_rect(color = "grey"),
+          axis.line = element_line(size = 0.5, colour = "grey"))
+  
+  plot = ggplotly(plot, tooltip = c("text")) %>% 
+    config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE) %>%
+    layout(yaxis=list(title='[EJ]', titlefont = list(size = 10)))
+  
+  vars = as.character(unique(dt$subtech))
+  
+  output = list(plot = plot,
+                vars = vars)
+  
+  return(output)
+}
+
 CO2km_intensity_newsalesdash = function(dt, scen){
   historical_values = data.table(year = c(2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018), emi = c(159, 157, 145, 140, 137, 132, 128, 124, 120, 119, 119, 120))
   historical_values[, details := "Historical values"]
@@ -286,6 +413,52 @@ CO2km_intensity_newsalesdash = function(dt, scen){
   return(plot)
 }
 
+
+CO2km_intensity_newsales_scen_dash = function(dt){
+  dt[, scenario := ifelse(scenario == "Base_ConvCase", "ConvCaseNoTax", scenario)]
+  historical_values = data.table(year = c(2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018), emi = c(159, 157, 145, 140, 137, 132, 128, 124, 120, 119, 119, 120))
+  historical_values[, details := "Historical values"]
+  targets = data.table(name = c("2021 target", "2025 target", "2030 target"), value = c(95, 95*(1-0.15), 95*(1-0.37)))
+  targets[, details := paste0("Policy target")] 
+  
+  targets[, details_blank := ""]
+  dt = dt[!is.na(gCO2_km_ave) & region == region_plot & year <= 2050]
+  dt[, scenario := gsub(".*_", "", scenario)]
+  dt[, details := paste0(scenario)]
+  
+  plot = ggplot()+
+    geom_line(data = dt[year >=2020], aes(x = year, y = gCO2_km_ave, color = scenario, text = details))+
+    geom_point(data = historical_values, aes(x = year, y = emi, text = details), color = "grey20")+
+    geom_hline(data = targets, aes(yintercept = value, linetype = name, text = details), color = "grey20", size=0.1)+
+    geom_text(data = targets, aes(y = value+5, x = c(2025, 2030, 2035), label = name, text = details_blank), size = 3)+
+    expand_limits(y = c(0,1))+
+    labs(x = "", y = "")+
+    scale_x_continuous(breaks = c(2015, 2030, 2050))+
+    theme_minimal()+
+    theme(axis.text.x = element_text(angle = 90,  size = 8, vjust=0.5, hjust=1),
+          axis.text.y = element_text(size = 8),
+          axis.title = element_text(size = 8),
+          title = element_text(size = 8),
+          legend.position = "none",
+          strip.text = element_text(size = 8),
+          strip.background = element_rect(color = "grey"),
+          axis.line = element_line(size = 0.5, colour = "grey"))+
+    guides(linetype = FALSE)+
+    scale_color_manual(values = cols)
+  
+  plot = ggplotly(plot, tooltip = c("text")) %>%
+    config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE) %>%
+    layout(yaxis=list(title='[gCO<sub>2</sub>/km]', titlefont = list(size = 10)))
+  
+  vars = as.character(unique(dt$scenario))
+  
+  output = list(plot = plot,
+                vars = vars)
+  
+  return(output)
+}
+
+
 EJLDVdash <- function(dt, scen){
   dt = dt[subsector_L1 == "trn_pass_road_LDV_4W"]
   dt[, technology := factor(technology, levels = legend_ord)]
@@ -298,6 +471,7 @@ EJLDVdash <- function(dt, scen){
     theme_minimal()+
     scale_fill_manual("Technology", values = cols, breaks=legend_ord)+
     expand_limits(y = c(0,1))+
+    ylim(0, 13)+
     scale_x_continuous(breaks = c(2015, 2030, 2050))+
     theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1),
           axis.text.y = element_text(size = 8),
@@ -329,6 +503,7 @@ emidem_dash = function(dt, scen){
     labs(x = "", y = "")+
     theme_minimal()+
     expand_limits(y = c(0,1))+
+    ylim(0,1250)+
     scale_x_continuous(breaks = c(2015, 2030, 2050))+
     theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1),
           axis.text.y = element_text(size = 8),
@@ -351,28 +526,37 @@ legend = list()
 
 create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfuels_all, CO2km_int_newsales_all, EJLDV_all){
   output = NULL
+  
+  ## for loop to produce scenario specific results
   for (scen in scens) {
     
     ## attribute scenario name
-    if (grepl("ConvCase", scen)) {
+    if (grepl("Budg1100_ConvCase", scen)) {
       scenname = "ConvCase"
-    } else if (grepl("ElecEra", scen)) {
+    } else if (grepl("Budg1100_ElecEra", scen)) {
       scenname = "ElecEra"
-    } else if (grepl("HydrHype", scen)) {
+    } else if (grepl("Budg1100_HydrHype", scen)) {
       scenname = "HydrHype"
-    } else if (grepl("SynSurge", scen)) {
+    } else if (grepl("Budg1100_SynSurge", scen)) {
       scenname = "SynSurge"
+    } else if (grepl("Base_ConvCase", scen)) {
+      scenname = "ConvCase NoTax"
     }
     
     ## CO2 tax pathway
     emiscen = gsub("_.*", "", scen)
+    emiscen_names = c("Budg1100" = "2 degrees target",
+                      "Base" = "Baseline")
+    emiscen = unname(emiscen_names[emiscen])
     
     ## sales
     salescomp = salescomdash(salescomp_all, scen)
     ## vintages
     vintcomp = vintcomparisondash(fleet_all, scen)
-    ## energy services demand
+    ## energy services demand per capita
     ESmodecap = ESmodecapdash(ESmodecap_all, scen)
+    ## energy services demand, total
+    ESmodeabs = ESmodeabs_dash(ESmodeabs_all, scen)
     ## final energy demand
     EJfuels = EJfuels_dash(EJfuels_all, scen) ## Final Energy demand all modes, passenger and freight
     ## CO2 intensity new sales LDVs
@@ -387,18 +571,34 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue
     output[[scenname]]$plot$salescomp = salescomp$plot
     output[[scenname]]$plot$ESmodecap_pass = ESmodecap$plot$plot_pass
     output[[scenname]]$plot$ESmodecap_frgt = ESmodecap$plot$plot_frgt
+    output[[scenname]]$plot$ESmodeabs = ESmodeabs$plot
     output[[scenname]]$plot$EJfuels = EJfuels$plot
     output[[scenname]]$plot$CO2km_int_newsales = CO2km_int_newsales
     output[[scenname]]$plot$EJLDV = EJLDV$plot
     output[[scenname]]$plot$emidem = emidem
     output[[scenname]]$emiscen = emiscen
   }
-    
+  
+  ## for loop to produce the comparison plots
+  ## vintages
+  vintscen = vintscen_dash(fleet_all)
+  ## CO2 intensity of new sales
+  CO2km_intensity_newsales_scen = CO2km_intensity_newsales_scen_dash(CO2km_int_newsales_all)
+  ## Final energy demand
+  EJfuels_scen = EJfuels_scen_dash(EJfuels_all)
+  
+  
+  output[["comparison"]]$plot$vintscen = vintscen$plot
+  output[["comparison"]]$plot$CO2km_intensity_newsales_scen = CO2km_intensity_newsales_scen$plot
+  output[["comparison"]]$plot$EJfuels_scen = EJfuels_scen$plot
+  
   
   legend$'Sales composition'$contents <- lapply(salescomp$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
   names(legend$'Sales composition'$contents) <- salescomp$vars
   legend$'Per capita Passenger Transport Energy Services Demand'$contents <- lapply(ESmodecap$vars$vars_pass, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
   names(legend$'Per capita Passenger Transport Energy Services Demand'$contents) <- ESmodecap$vars$vars_pass
+  legend$'Total Passenger Transport Energy Services Demand'$contents <- lapply(ESmodeabs$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
+  names(legend$'Total Passenger Transport Energy Services Demand'$contents) <- ESmodeabs$vars
   legend$'Per capita Freight Transport Energy Services Demand'$contents <- lapply(ESmodecap$vars$vars_frgt, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
   names(legend$'Per capita Freight Transport Energy Services Demand'$contents) <- ESmodecap$vars$vars_frgt
   legend$'Final energy LDVs by fuel'$contents <- lapply(EJLDV$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
@@ -407,7 +607,15 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue
   names(legend$'Transport Final Energy Demand'$contents) <- EJfuels$vars
   legend$'Fleet composition'$contents <- lapply(vintcomp$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
   names(legend$'Fleet composition'$contents) <- vintcomp$vars
-
+  
+  
+  legend$'Fleet composition comparison'$contents <- lapply(vintscen$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
+  names(legend$'Fleet composition comparison'$contents) <- vintscen$vars
+  legend$'Emission intensity, new sales comparison'$contents <- lapply(CO2km_intensity_newsales_scen$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
+  names(legend$'Emission intensity, new sales comparison'$contents) <- CO2km_intensity_newsales_scen$vars
+  legend$'Comparison of final energy demand'$contents <- lapply(EJfuels_scen$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
+  names(legend$'Comparison of final energy demand'$contents) <- EJfuels_scen$vars
+  
   output$legend = legend
   return(output)
   
diff --git a/scripts/output/single/notebook_templates/EDGETransportReport.Rmd b/scripts/output/single/notebook_templates/EDGETransportReport.Rmd
index 72472bf..1d13944 100644
--- a/scripts/output/single/notebook_templates/EDGETransportReport.Rmd
+++ b/scripts/output/single/notebook_templates/EDGETransportReport.Rmd
@@ -197,7 +197,7 @@ p
 plotinconv = function(inco_tech, iso_plot, vehicle_type){
   p=ggplot()+
   geom_bar(data = inco_tech[iso == iso_plot & subsector_L1 == "trn_pass_road_LDV_4W" & vehicle_type == vehicle_type & year<=2100 & year>=2010], aes(x = as.character(year), y = value, group = logit_type, fill = logit_type), position = position_stack(), stat = "identity")+
-  facet_wrap(~technology, norw = 3)+
+  facet_wrap(~technology, nrow = 3)+
   theme_minimal()+
   # scale_fill_manual(values = cols)+
   expand_limits(y = c(0,0.8))+
-- 
GitLab