Line column chart with R
A line column chart is a type of visualization that combines both line and column charts together, using dual axes displayed on the left and right sides of the chart.
More about: Line column chart
Line column chart
# Loading required packages
library(unhcrthemes)
library(tidyverse)
library(scales)
# Loading data
<- read_csv("https://raw.githubusercontent.com/GDS-ODSSS/unhcr-dataviz-platform/master/data/change_over_time/line_column.csv")
df
# Plot
ggplot(data = df) +
geom_col(aes(year,
displaced_population,fill = "Displaced population"
),width = 0.7
+
) geom_line(aes(year,
* 10,
displaced_proportion color = "Proportion displaced"
),size = 1
+
) scale_fill_manual(values = setNames(
unhcr_pal(n = 1, "pal_blue"),
"Displaced population"
+
)) scale_color_manual(values = setNames(
unhcr_pal(n = 1, "pal_red"),
"Proportion displaced"
+
)) labs(
title = "Trend of global displacement | 2007 - 2016",
caption = "Source: UNHCR Refugee Data Finder\n© UNHCR, The UN Refugee Agency"
+
) scale_x_continuous(breaks = pretty_breaks(n = nrow(df))) +
scale_y_continuous("Displaced population (millions)",
expand = expansion(c(0, 0.2)),
breaks = pretty_breaks(),
sec.axis = sec_axis(~ . / 10,
breaks = pretty_breaks(),
name = "Proportion displaced (number displaced per 1,000)"
)+
) theme_unhcr(
grid = "Y",
axis_title = "y"
)