-
Notifications
You must be signed in to change notification settings - Fork 2
/
windLCA.R
48 lines (44 loc) · 2.54 KB
/
windLCA.R
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
library(dplyr)
library(ggplot2)
type <- c("Wind", "Wind", "Wind", "Wind", "Gas", "Gas", "Gas", "Gas")
cost <- c("Price", "CO2 DALY", "PM2.5 DALY", "Social Cost of Carbon", "Price", "CO2 DALY", "PM2.5 DALY", "Social Cost of Carbon")
cost = factor(cost, levels = c("Price", "CO2 DALY", "PM2.5 DALY", "Social Cost of Carbon"))
valu <- c( 0.9, 0.0145, 0.0853, 0.00596, 0.1273, 0.0983, 0.1529, 0.0363)
high <- c( 0.9, 1.24, 0.639, 0.0748, 0.1273, 8.45, 1.146, 0.456)
lows <- c( 0.9, 0.00755, 0.0081, 0.000117, 0.1273, 0.00515, 0.0145, 0.00071)
dat <- data.frame(type, cost, valu, high, lows)
full <- ggplot(dat, aes(fill=cost, y=valu, x=type)) +
geom_bar(position="stack", stat="identity", show.legend = FALSE) +
xlab("") +
ylab("Cost ($/kWh)") +
guides(fill=guide_legend(title="Impact Categories")) +
theme(panel.background = element_rect(fill = "white", colour = "black")) +
theme(aspect.ratio = 1.6,
panel.background = element_rect(fill = "white", colour = "black")) +
theme(axis.text = element_text(face = "plain", size = 11),
axis.title = element_text(face = "plain", size = 11)) +
theme(legend.position="right",
legend.key = element_blank(),
legend.text = element_text(face = "plain", size = 11),
legend.title = element_text(face = "plain", size = 11))
gfull <- ggplotGrob(full)
werr <- ggplot(dat, aes(fill=cost, y=valu, x=type)) +
geom_bar(position="dodge", stat="identity") +
geom_errorbar(aes(ymin = lows, ymax = high), width = 0.3, position = position_dodge(0.9)) +
coord_cartesian(ylim = c(0,1.5)) +
xlab("") +
ylab("") +
annotate("text", x="Gas", y=1.4, label = " max=8.45", size = 3) +
guides(fill=guide_legend(title="Impact Categories")) +
theme(panel.background = element_rect(fill = "white", colour = "black")) +
theme(aspect.ratio = 1.6,
panel.background = element_rect(fill = "white", colour = "black")) +
theme(axis.text = element_text(face = "plain", size = 11),
axis.title = element_text(face = "plain", size = 11)) +
theme(legend.position="right",
legend.key = element_blank(),
legend.text = element_text(face = "plain", size = 11),
legend.title = element_text(face = "plain", size = 11))
gwerr <- ggplotGrob(werr)
grid::grid.newpage()
tot <- grid::grid.draw(cbind(gfull,gwerr))