Data Science for Social Science Research
Najah
Ashoka University
ggplot
Visualggplot(gm_07, aes(x = gdpPercap, y = lifeExp, fill = continent, size = pop ))+
geom_point(alpha = 0.5, shape = 21, color = "black")+
#scale_x_log10()+
scale_x_continuous(
labels = scales::dollar_format(),
breaks = scales::log_breaks(n = 10)
) +
coord_trans(x = 'log10') +
scale_size_continuous(
labels = scales::number_format(scale = 1e-6, suffix = "m"),
breaks = seq(1e8,1e9, 2e8),
range = c(1,20)
)+
labs(
title = "An Example of Hans Rosling's Gapminder using ggplot",
x = "GDP per Capita (log scale)",
y = "Life Expectancy at Birth",
size = "Population",
color = NULL,
caption = "Source: Gapminder"
) +
theme_bw() +
annotate("text", x = 3000, y = 60, hjust = 0.5,
size = 40, color = "#999999",
label = "2007", alpha = .3,
family = "Helvetica Neue")
Add dollar sign
specify the log breaks