Introduction

The chart below displays the forested area in European countries as a share of total land area in the year 2020. Data comes from the World Bank’s Atlas of Sustainable Development Goals: https://sdga2022.github.io/sdga2022/goal-15-life-on-land?lang=en. The chart used is a circular bar plot. The code is based on the example given in the R Graph Gallery: https://r-graph-gallery.com/295-basic-circular-barplot.html.

Data wrangling

# Prepare Europe data
df_eur <- df %>%
  filter(continent=="Europe") %>%
  subset(forests_2000 != 0)

# Prepare dataframe to have an id column with number of observations
df_eur <- tibble::rowid_to_column(df_eur, "id")

Plot production

p <- df_eur %>%
  
  # round forests_2020 to remove decimals 
  mutate(forests_2020_r = round(forests_2020, digits = 0)) %>%
  
  # add new column "label" as a merge from iso3c and forests_2020
  unite(label, "iso3c", "forests_2020_r", sep = "\n", remove = FALSE) %>%
  
  # reorder bars 
  mutate(iso3c = fct_reorder(iso3c, forests_2020_r)) %>%
  
  ggplot(aes(x=as.factor(iso3c), y=forests_2020_r)) + 
  
  # This add the bars with a green color
  geom_bar(stat="identity", fill=alpha("darkgreen", 0.5)) +
  
  # Limits of the plot = very important. The negative value controls the size of the inner circle, the positive one is useful to add size over each bar
  ylim(-110,100) +
  
  # Custom the theme: no axis title and no cartesian grid
  theme_minimal() +
  labs(title = "\n \n Forest area in European countries as a share of total land area\n(year 2020, in %)",
       caption = "Data source: https://sdga2022.github.io/sdga2022/goal-15-life-on-land?lang=en \n \n \n \n \n \n \n \n") + 
  theme(
    axis.text = element_blank(),
    axis.title = element_blank(),
    panel.grid = element_blank(),
    plot.caption.position = "plot",
    plot.caption = element_text(hjust = 0.5, colour = "chocolate4", family = "Optima", face="bold.italic"),
    plot.background = element_rect(colour = "white"),
    plot.title = element_text(hjust = 0.5, colour = "chocolate4", face = "bold", family = "Optima"), # https://stackoverflow.com/questions/67748464/plot-title-not-working-in-circular-barplot
    plot.margin = unit(c(-0.7, 0, 0, 0), "cm")     # This remove unnecessary margin around plot
  ) +
  
  # This makes the coordinate polar instead of cartesian.
  coord_polar(start = 0) + 
  
  # Add the labels
  geom_text(aes(x=iso3c, y=forests_2020_r+25, label=label, lineheight = 0.8), color="chocolate4", family = "Optima", fontface="bold", size=2.5, inherit.aes = FALSE) 
p