-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSensitivity3A_PandD.R
More file actions
130 lines (82 loc) · 6.39 KB
/
Copy pathSensitivity3A_PandD.R
File metadata and controls
130 lines (82 loc) · 6.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
library(plotly)
library(Hmisc)
library(reshape2)
library(ggplot2)
library(plyr)
library(wesanderson)
library(RColorBrewer)
library(readxl)
Production_electricity_cost <- read_excel("~/WORK_PROJECTS/Iwb/IWB/Results_Final/R_data/Sensitivity/Sensitivity_3A_Case2/Production_electricity_cost.xlsx")
data<- Production_electricity_cost
df <-melt(as.data.frame(data),c("Years", "Case"))
df$cat <- ''
df[df$variable != 'Demand + HPs + E-Mobility' & df$Case =='Base',]$cat <- "P Base Case"
df[df$variable == 'Demand + HPs + E-Mobility' & df$Case =='Base',]$cat <- "D Base Case"
df[df$variable != 'Demand + HPs + E-Mobility' & df$Case =='Case2',]$cat <- "P Case 2"
df[df$variable == 'Demand + HPs + E-Mobility' & df$Case =='Case2',]$cat <- "D Case 2"
cols <- c("Grid Import" = "#4393C3", "DH CHP (gas)" = "#D6604D","DH CHP (wood)" = "#954335","DH CHP (waste)" = "#6b3026", "Hydroelectricity CH" = "#E0E0E0",
"Hydroelectricity BS" = "#878787","PV"="#4D4D4D", "Micro-CHP (gas)"="#eaafa6", "Demand + HPs + E-Mobility"="#ffd662")
p4<-ggplot(data=df, aes(x = cat, y = value, fill=factor(variable, levels=c("Grid Import","Hydroelectricity CH",
"Hydroelectricity BS","DH CHP (gas)","DH CHP (wood)","DH CHP (waste)","Micro-CHP (gas)", "PV", "Demand + HPs + E-Mobility")),width = .6)) +
geom_bar(stat = 'identity', position = 'stack') + facet_grid(. ~Years )+scale_fill_manual(values=cols)+
labs(x="",y="GWh/year") + scale_x_discrete(limits = c("D Base Case","P Base Case","D Case 2","P Case 2")) +
theme_light() + theme(legend.title=element_blank())+theme(text = element_text(size = 12))+
theme(axis.text.x = element_text(angle = 50, hjust = 1))
p4
# heat
Production_heat_cost <- read_excel("~/WORK_PROJECTS/Iwb/IWB/Results_Final/R_data/Sensitivity/Sensitivity_3A_Case2/Production_heat_cost.xlsx")
data<- Production_heat_cost
df <-melt(as.data.frame(data),c("Years", "Case"))
df$cat <- ''
df[df$variable == 'Heat demand' & df$Case =='Base',]$cat <- "Demand"
df[df$variable != 'Heat demand' & df$Case == 'Base',]$cat <- "P Base Case"
df[df$variable != 'Heat demand' & df$Case =='Case2',]$cat <- "P Case 2"
df[df$variable == 'Heat demand' & df$Case =='Case2',]$cat <- "D Case 2"
cols <- c("Oil boilers" = "#CCCC33", "Gas boilers" = "#339966", "Wood boilers" = "#CCCC99",
"Waste boilers" = "#999966","HP"="#FF9900","Solar TH"="#FFCC00","DH gas"="#CC6600",
"Gas-HP"="#9999CC","Micro-CHP"= "#006666", "DH wood" = "#993300", "DH waste"="#0066CC", "DH HP"="#FFCC66","Heat demand"= "#999999")
p4<-ggplot(data=df, aes(x = cat, y = value, fill=factor(variable, levels=c("Solar TH","Micro-CHP","Oil boilers","Gas boilers","Wood boilers","Waste boilers",
"HP", "Gas-HP","DH HP","DH gas",
"DH wood", "DH waste", "Heat demand")),width = .6)) +
geom_bar(stat = 'identity', position = 'stack') + facet_grid(~ Years)+scale_fill_manual(values=cols)+
labs(x="",y="GWh/year") + scale_x_discrete(limits = c("Demand","P Base Case","P Case 2"))+
theme_light() + theme(legend.title=element_blank())+theme(text = element_text(size = 12))+
theme(axis.text.x = element_text(angle = 50, hjust = 1))
p4
#stacked
p4<-ggplot(data=df, aes(x = cat, y = value, fill=factor(variable, levels=c("Grid Import","Hydroelectricity CH",
"Hydroelectricity BS","DH CHP (gas)","DH CHP (wood)","DH CHP (waste)","Micro-CHP (gas)", "PV", "Demand + HPs + E-Mobility")),width = .6)) +
geom_bar(stat = 'identity', position = 'stack') + facet_grid( Years ~. )+scale_fill_manual(values=cols)+
labs(x="",y="GWh/year") + scale_x_discrete(limits = c("D BC","P BC","D C2","P C2")) +
theme_minimal() + theme(legend.title=element_blank())+theme(text = element_text(size = 12))
p4
#stacked
p4<-ggplot(data=df, aes(x = cat, y = value, fill=factor(variable, levels=c("Solar TH","Micro-CHP","Oil boilers","Gas boilers","Wood boilers","Waste boilers",
"HP", "Gas-HP","DH HP","DH gas",
"DH wood", "DH waste", "Heat demand")),width = .4)) +
geom_bar(stat = 'identity', position = 'stack') + facet_grid( Years ~.)+scale_fill_manual(values=cols)+
labs(x="",y="GWh/year") +scale_x_discrete(limits = c("D BC","P BC","D C2","P C2"))+
theme_minimal() + theme(legend.title=element_blank())+theme(text = element_text(size = 12))
p4
#production only graph
h<- subset(df,df$variable %in% c("2014", "Demand + HPs + E-Mobility"))
g<- subset(df,df$variable %in% c("PV", "Hydroelectricity BS","Hydroelectricity CH","micro-CHP","Grid Import"))
p4 <- ggplot(data=df, aes(x=Years, y=value)) +
geom_bar(data=df,stat="identity", aes(fill=factor(variable, levels=c("Grid Import","Hydroelectricity CH",
"Hydroelectricity BS","CHP","micro-CHP", "PV", "Demand + HPs + E-Mobility"))),width = 8,
position='stack') +
scale_fill_manual(values=cols)+
labs(x="Years",y="GWh/year") + scale_x_continuous(breaks=c(2020, 2035, 2050)) +
theme_minimal() + theme(legend.title=element_blank())+ ggtitle("Electricity production")+theme(text = element_text(size = 12))+facet_grid( ~ Years)
p4
#prodcution graph only
df2 <-subset(df,df$variable %in% c("Months","Oil boilers","Gas boilers","Wood boilers","Waste boilers","HP", "ST",
"Gas HP", "micro-CHP","DH gas", "DH wood", "DH Waste", "DH HP"))
p4 <- ggplot(data=df, aes(x=Years, y=value)) +
geom_bar(data=df2,stat="identity", aes(fill=factor(variable, levels=c("ST","micro-CHP","Oil boilers","Gas boilers","Wood boilers","Waste boilers",
"HP", "Gas HP","DH HP","DH gas",
"DH wood", "DH Waste" ))),width = 8) +
scale_fill_manual(values=cols)+
labs(x="Years",y="GWh/year") + scale_x_continuous(breaks=c(2020, 2035, 2050)) +
theme_minimal() + theme(legend.title=element_blank())+ ggtitle("Heat production")+theme(text = element_text(size = 12))
p4