Recreate charts in: REPORT ON SOCIO-ECONOMIC SITUATION IN THE 4TH QUARTER AND 2023
Source: GSO
In 2023, the estimated total retail sales of goods and consumer service revenue, based on current prices, reached 6,231.8 trillion VND, representing a 9.6% increase compared to the previous year (2022 saw a 20% growth). If we exclude the impact of price increases (which rose by 7.1% in 2022), the growth rate remains impressive.
# Visualizing 2 series with R and ggplot2
library(tidyverse)
library(patchwork)
library(ggtext)
total1 <- retail %>%
filter(year != 2022)
total2 <- retail %>%
filter(year == 2022)
text <- "In **2023**, the estimated **total retail sales of goods and consumer service revenue**, based on current prices, reached <span style = 'color:#B2533E'>**6,231.8 trillion VND**</span>, representing a <span style = 'color:#071952'>**9.6% increase**</span> compared to the previous year (2022 saw a <span style = 'color:#071952'>**20% growth**</span>). If we **exclude the impact of price increases** (which rose by **7.1%** in 2022), the growth rate remains impressive."
df_text <- data.frame(year = 2019, total = 9000, growth_rate = 12.5, text = text)
ggplot(retail, aes(x=year))+
geom_bar(aes(y=total),stat = "identity", fill = "#B2533E")+
geom_line(aes(y=growth_rate*200+2000), size = 1, color = "#071952")+
geom_point(aes(y=growth_rate*200+2000), size = 3, color = "#071952")+
# Custom the Y scales:
scale_y_continuous(
# Features of the first axis
name = "Total (trillion VND)",
breaks = seq(0, 7000, by = 2000),
limits = c(0, 9000),
# Add a second axis and specify its features
sec.axis = sec_axis(~.*0.005-10, name="Growth rate (%)")
)+
# Theme
theme_minimal()+
# Edit background and gridline
theme(panel.grid.minor = element_blank())+
theme(panel.grid.major.x = element_blank())+
theme(plot.background = element_rect(fill = "#F6F4EB", color = "#F6F4EB")) +
theme(panel.background = element_rect(fill = "#F6F4EB", color = "#F6F4EB"))+
theme(panel.grid.major.y = element_line(color = "grey80", linewidth = 0.1))+
# Edit axis
theme(axis.title.x = element_blank())+
theme(axis.title.y = element_text(size = 7, face = "bold", color = "#B2533E"))+
theme(axis.text.y = element_blank())+
theme(axis.title.y.right = element_text(size = 7, face = "bold",color = "#071952"))+
theme(axis.text.y.right = element_blank())+
theme(axis.text.x = element_text(size = 10, face = "bold", color = "grey30"))+
# Add label
geom_text(data = total1, aes(year, total+300, label = total), size = 4,
color = "#B2533E", show.legend = FALSE)+
geom_text(data = total2, aes(year, total+800, label = total), size = 4,
color = "#B2533E", show.legend = FALSE)+
geom_text(data = retail, aes(year, growth_rate*200+1500, label = growth_rate), size = 3.5,
color = "#071952", show.legend = FALSE)+
labs(title = "Figure 8: Total retail sales of goods and\nConsumer service revenue from 2019-2023",
subtitle = "Sources: GSO",
caption = "Recreate: Thao Bui")+
theme(plot.title.position = "plot")+
theme(plot.title = element_text(size = 15,face = "bold", color = "grey30")) +
theme(plot.subtitle = element_text(size = 10, face = "italic", color = "grey50")) +
theme(plot.caption = element_text(size = 7, face = "italic", color = "grey50"))+
# Adjust plot margin
theme(plot.margin = unit(c(0.5, 0.5, 0.1, 0.5), "cm"))+
# Add text box
geom_textbox(
data = df_text,
aes(x = year, y = total , label = text, box.color = NA),
width = 0.7,
hjust = 0.2,
vjust = 1,
fill = NA,
color = "grey50",
size = 2.2
)
ggsave("retail.png", width = 6, height = 4,dpi = 300,units = c("in"))