Data examples using World Bank Data in combination with the ggplot package in R.
Tidyverse methods and functions were used to generate a combined data frame (tibble) for all countries and indicators.
countries.wb.data.map %>% filter( country == c("Afghanistan","Germany","Mexico") ) %>% ggplot( aes( x = `year` , y = `Population, total`, #size = `Population, total`, col = `country` #chape = `Region` ) ) + geom_point( ) + labs( title = "Population" )
countries.wb.data.map %>% filter( year > 2017 ) %>% filter( year < 2019 ) %>% #filter( country == c("Austria","Germany","France") ) %>% ggplot( aes( x = log( `GDP (constant 2010 US$)` ) , y = `Fertility rate, total (births per woman)`, size = `Population, total`, shape = `IncomeGroup`, col = `Region` #shape = as.character(`year`) ) ) + geom_point( ) + labs( title = "log( `GDP (constant 2010 US$)` ) vs. Fertility rate, total (births per woman)" )
countries.wb.data.map %>% filter( year > 2017 ) %>% filter( year < 2019 ) %>% #filter( country == c("Austria","Germany","France") ) %>% ggplot( aes( x = `GDP per capita (constant 2010 US$)`, y = `Fertility rate, total (births per woman)`, #size = `Population, total`, shape = `IncomeGroup`, col = `Region` #shape = as.character(`year`) ) ) + geom_point( ) + labs( title = "GDP per capita (constant 2010 US$) vs Fertility rate, total (births per woman)" ) + geom_label_repel( aes( label = ifelse( `IncomeGroup` == "Low income", country, "" ) ), hjust=0, #vjust=0.5, #nudge_y = 7, nudge_x = 150000, #force = 100, box.padding = 0.35, point.padding = 0.2, segment.color = "lightgray", direction = "y", # limits movement to x axis #color = "white", arrow = arrow( length = unit(0.03, "npc"), type = "closed", ends = "first" ) ) + #xlim( - 100, 60000000000000) + #scale_x_continuous( expand = expand_scale(mult = c( 0.4, 0.4 ))) + #scale_y_continuous( expand = expand_scale(mult = c( 0.1, 0.1))) + theme_bw()
countries.wb.data.map %>% filter( year > 2017 ) %>% filter( year < 2019 ) %>% #filter( country == c("Austria","Germany","France") ) %>% ggplot( aes( x = `GDP per capita (constant 2010 US$)`, y = `Fertility rate, total (births per woman)`, #size = `Population, total`, #shape = `IncomeGroup`, col = `IncomeGroup` #shape = as.character(`year`) ) ) + geom_point( ) + geom_line() + geom_smooth() + theme_bw() + labs( title = "log( GDP per capita (constant 2010 US$) ) - Fertility rate, total (births per woman) " ) + xlim( 0, 50000 )
countries.wb.data.map %>% filter( year > 2017 ) %>% filter( year < 2019 ) %>% #filter( country == c("Austria","Germany","France") ) %>% ggplot( aes( x = log( `GDP per capita (constant 2010 US$)` ), y = `Fertility rate, total (births per woman)`, #size = `Population, total`, #shape = `IncomeGroup`, col = `IncomeGroup` #shape = as.character(`year`) ) ) + geom_point( ) + geom_line() + geom_smooth() + theme_bw() + labs( title = "log( GDP per capita (constant 2010 US$) ) - Fertility rate, total (births per woman) " )
countries.wb.data.map %>% filter( year > 2017 ) %>% filter( year < 2019 ) %>% #filter( country == c("Austria","Germany","France") ) %>% ggplot( aes( x = log( `GDP per capita (constant 2010 US$)` ), y = `Fertility rate, total (births per woman)` #size = `Population, total`, #shape = `IncomeGroup`, #col = `Region` #shape = as.character(`year`) ) ) + geom_line() + geom_smooth() + labs( title = "GDP per capita (constant 2010 US$) vs Fertility rate, total (births per woman) 2018" ) + geom_point( aes( x = log( `GDP per capita (constant 2010 US$)` ), y = `Fertility rate, total (births per woman)`, #size = `IncomeGroup`, shape = `IncomeGroup`, col = `Region` #shape = as.character(`year`) ) ) + geom_label_repel( aes( label = ifelse( `Fertility rate, total (births per woman)` > 5, `country`, "" ) ), hjust=0, #vjust=4, #nudge_y = 7, nudge_x = 11, #force = 100, #box.padding = 0.9, #point.padding = 0.2, segment.color = "lightgray", direction = "y" # limits movement to x axis #color = "white", #arrow = arrow( # length = unit(0.03, "npc"), # type = "closed", # ends = "first" ) ) + geom_label_repel( aes( label = ifelse( `Fertility rate, total (births per woman)` < 1.25, `country`, "" ) ), #hjust=5, #vjust=2, #nudge_y = 0, nudge_x = -11, #force = 100, #box.padding = 0.9, point.padding = 0.2, segment.color = "lightgray", direction = "y" # limits movement to x axis #color = "white", #arrow = arrow( # length = unit(0.03, "npc"), # type = "closed", # ends = "first" ) )
countries.wb.data.map %>% filter( year > 1980 ) %>% filter( year < 1982 ) %>% #filter( country == c("Austria","Germany","France") ) %>% ggplot( aes( x = log( `GDP per capita (constant 2010 US$)` ), y = `Fertility rate, total (births per woman)` #size = `Population, total`, #shape = `IncomeGroup`, #col = `Region` #shape = as.character(`year`) ) ) + geom_line() + geom_smooth() + labs( title = "GDP per capita (constant 2010 US$) vs Fertility rate, total (births per woman) 1981" ) + geom_point( aes( x = log( `GDP per capita (constant 2010 US$)` ), y = `Fertility rate, total (births per woman)`, #size = `IncomeGroup`, shape = `IncomeGroup`, col = `Region` #shape = as.character(`year`) ) ) + geom_label_repel( aes( label = ifelse( `Fertility rate, total (births per woman)` > 7.3, `country`, "" ) ), hjust=0, #vjust=4, #nudge_y = 7, nudge_x = 11, #force = 100, #box.padding = 0.9, #point.padding = 0.2, segment.color = "lightgray", direction = "y" # limits movement to x axis #color = "white", #arrow = arrow( # length = unit(0.03, "npc"), # type = "closed", # ends = "first" ) ) + geom_label_repel( aes( label = ifelse( `Fertility rate, total (births per woman)` < 1.8, `country`, "" ) ), #hjust=5, #vjust=2, #nudge_y = 0, nudge_x = -11, #force = 100, #box.padding = 0.9, point.padding = 0.2, segment.color = "lightgray", direction = "y" # limits movement to x axis #color = "white", #arrow = arrow( # length = unit(0.03, "npc"), # type = "closed", # ends = "first" ) )
countries.wb.data.map %>% filter( country == c("Austria","Germany", "France" ) ) %>% filter( year > 1960 ) %>% filter( year < 2019 ) %>% ggplot( aes( x = log( `GDP per capita (constant 2010 US$)` ), y = `Fertility rate, total (births per woman)`, #size = `Population, total`, #shape = `IncomeGroup`, col = `country` #shape = as.character(`year`) ) ) + geom_line( ) + geom_smooth() + geom_point( ) + geom_label_repel( aes( label = ifelse( `country` == "France", `year`, "" ) ), #hjust=3, #vjust=-4, nudge_y = 1, #nudge_x = 9, #force = 100, #box.padding = 0.9, #point.padding = 0.2, segment.color = "lightgray", direction = "y" # limits movement to x axis #color = "white", #arrow = arrow( # length = unit(0.03, "npc"), # type = "closed", # ends = "first" ) ) + geom_label_repel( aes( label = ifelse( `country` == "Austria", `year`, "" ) ), #hjust=3, #vjust=-3, #nudge_y = 1, nudge_x = -3, #force = 100, #box.padding = 0.9, #point.padding = 0.2, segment.color = "lightgray", direction = "x" # limits movement to x axis #color = "white", #arrow = arrow( # length = unit(0.03, "npc"), # type = "closed", # ends = "first" ) ) + geom_label_repel( aes( label = ifelse( `country` == "Germany", `year`, "" ) ), #hjust=3, #vjust=2, nudge_y = -4, #nudge_x = 9, #force = 100, #box.padding = 0.9, #point.padding = 0.2, segment.color = "lightgray", direction = "y" # limits movement to x axis #color = "white", #arrow = arrow( # length = unit(0.03, "npc"), # type = "closed", # ends = "first" ) ) + theme_bw() + labs( title = "log( `GDP per capita (constant 2010 US$)` ) - Fertility rate, total (births per woman) 1961 - 2018" )