Skip to content

Instantly share code, notes, and snippets.

@matteodefelice
Created May 5, 2020 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matteodefelice/0cdd3089a481cb179cb530434641fdc3 to your computer and use it in GitHub Desktop.
Save matteodefelice/0cdd3089a481cb179cb530434641fdc3 to your computer and use it in GitHub Desktop.
color_palette = c(
'Biomass' = '#7daf4bff',
'Coal' = '#af4b91b2',
'Gas' = '#d7642dff',
'Hydro-power' = '#00a0e1ff',
'Nuclear' = '#466eb4ff',
'Oil' = '#af4b91ff',
'Other' = '#b9c33799',
'Solar' = '#e6a532ff',
'Waste' = '#b9c337ff',
'Wind Power' = '#41afaaff'
)
# Change order of factors
sel = sel %>%
mutate(label = as.factor(label) %>%
fct_relevel('Solar', 'Gas', 'Wind Power', 'Hydro-power', 'Other', 'Coal', 'Biomass', 'Waste', 'Nuclear')
)
ggplot(sel, aes(x = DateTime, y = generation/1000, fill = label)) +
geom_area(position = 'stack') +
scale_fill_manual(values = color_palette, name = '')+
theme_light() + ylab('Actual Generation (GW)') +
xlab('Date') +
scale_y_continuous(breaks = seq(0, 500, 50), limits = c(0, 500))+
labs(title = 'European electricity generation in April 2020',
subtitle = 'Country hourly/sub-hourly data from ENTSO-E Transparency Platform',
caption = 'Data retrieved 04/05/2020') +
scale_x_datetime(breaks = c(make_datetime(2020, 4, 6, 0,0,0),
make_datetime(2020, 4, 13, 0,0,0),
make_datetime(2020, 4, 20, 0,0,0),
make_datetime(2020, 4, 27, 0,0,0)
)
)+
theme(panel.grid.minor = element_blank())
ggsave('entsoe-generation-april-2020.png', width = 8, height = 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment