Reputation: 143
I want to re-produce the following figure I did on excel + MS.pptx. I am doing this because I want a most sophisticated figure. However, I am struggling a lot.
I am using ggplot2 in R but struggling with facet
data %>%
ggplot(aes(x = year,
y = metric )) +
geom_bar(stat = "identity") +
theme_bw() +
theme(panel.grid = element_blank()) +
facet_wrap(~scenario)
Here you can find the reproducible data.
Any guidance to start the figure is very much appreciated.
Upvotes: 1
Views: 1527
Reputation: 7163
ggplot(dat, aes(year, value, fill=fuel)) +
geom_col() +
facet_grid(metric~scenario, scales="free", space="fixed") +
scale_x_continuous(breaks=c(2010, 2030, 2050)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
Upvotes: 1