Greenenergy

Welcome to #30DayChartChallenge 2023 day 22

Networks
Published

April 22, 2023

Gazzelloni F. (2023), Data Visualization: Green energy

As for the term “Green Energy”, it typically refers to energy that is produced from renewable sources, such as wind, solar, hydro, and geothermal power.

# source: https://github.com/bydata/30DayChartChallenge/blob/main/2023/22/22-green-energy.R

library(tidyverse)
library(ggtext)
library(showtext)
showtext_auto()
# Set fonts
font_add_google("Fira Sans","fira")


library(eurostat)

#base_path <- here("2023", "22")

#' Source: Eurostat
df <- get_eurostat("nrg_ind_ren", 
                   time_format = "num", 
                   type = "code"  # get variable codes and labels
)

df <- label_eurostat(df, code = "geo", fix_duplicated = TRUE)

# which countries?
unique(df$geo)
unique(df$geo_code)

eu_geo_codes <- c("AT", "BE", "BG", "CY", "CZ", "DE", "DK", "EE", "EL",
                  "ES", "EU27_2020", "FI", "FR", "HR", "HU", "IE", "IT", "LT",
                  "LU", "LV", "MT", "NL", "PL", "PT", "RO", "SE", "SI", "SK" )



df%>%dim

df1 <- df %>% 
  filter(geo_code %in% eu_geo_codes) %>% 
  mutate(geo = case_match(
    geo,
    "Germany (until 1990 former territory of the FRG)" ~ "Germany",
    "European Union - 27 countries (from 2020)" ~ "EU 27",
    .default = geo
  )) 


df1%>%count(nrg_bal)

df1%>%
  filter(nrg_bal=="Renewable energy sources in transport")


df1 %>%#count(geo)%>%View
  ggplot(aes(time,values,group=geo,color=geo))+
  geom_line(color="grey80")+
  geom_line(data=df1%>%
              filter(geo%in%c("Italy","EU 27","Spain","Germany","France")),
            inherit.aes = TRUE)+
  facet_wrap(~nrg_bal,scales = "free_y")+
  ggthemes::scale_color_calc()+
  labs(title="Renewable energy sources",
       color="",
       caption="DataSource: {eurostat} | #30DayChartChallenge day22: Green Energy\nDataViz: Federica Gazzelloni")+
  ggthemes::theme_calc()+
  theme(text = element_text(family="fira"),
        plot.title = element_text(size=24),
        axis.title.x = element_blank(),
        strip.background = element_rect(color="#be2d42",fill="#be2d42"),
        strip.text = element_text(color="white"))