Fund specific themes for Article IV

Set-ups

We first load a few libraries:

library(haven)
library(dplyr)
library(ggplot2)
library(here)

Next we run some code to set up themes and fonts

source(here("utils/theme_and_colors_IMF.R"))

We set up the primary font for charts to Segoe UI .

primary_font="Segoe UI"

Read WEO data

weo <- read_dta(here("databases/WEOApr2023Pub.dta"))
weo_us <- weo %>% 
  filter(ifscode==111) %>%
  select(ifscode, year, lur, pcpi_pch) 

#Filtering to only include 1980 data onwards
weo_us <- subset(weo_us, year >= 1980)

After running the set-ups, we are able to plot Article IV standard charts by adding the IMF theme component to ggplot. Let’s compare the layouts using our previous example.

Chart without Article IV format

gg <- ggplot(data = weo_us, aes(x = lur, y = pcpi_pch)) + 
  geom_point(color=blue,size=2.5) + 
  labs(title = "US: unemployment and inflation", 
       x = "Unemployment (percent)", y = "Inflation (percent)")

gg

Chart with Article IV format

gg_imf <- ggplot(data = weo_us, aes(x = lur, y = pcpi_pch)) + 
  geom_point(color=blue,size=2.5) + 
  labs(title = "US: unemployment and inflation", 
       x = "Unemployment (percent)", y = "Inflation (percent)") +
   theme_imf()

plot(gg_imf)

This is also a pre-custom setting when using our internal bookr library. In this case, all you would need to do is load the library bookr, and use the same code as before, without explicitly specifying theme imf, as it would be applied automatically.

#Load internal bookr library
library(bookr)
Bookr package has been loaded.

Attaching package: 'bookr'
The following objects are masked _by_ '.GlobalEnv':

    A4_colors, A4_colors_bar, rgb2, theme_imf, theme_imf_panel
gg <- ggplot(data = weo_us, aes(x = lur, y = pcpi_pch)) + 
  geom_point(color=blue,size=2.5) + 
  labs(title = "US: unemployment and inflation", 
       x = "Unemployment (percent)", y = "Inflation (percent)")

gg