ggplot(___) +
geom_point(
mapping = aes(x = ___, y = ___,
color = ___,
size  = ___),
alpha  = ___
)
View Interactive Version

For the gapminder_2007 dataset we can plot the GDP per capita gdpPercap vs. the life expectancy as follows:

Input
ggplot(gapminder_2007) +
geom_point(aes(x = gdpPercap, y = lifeExp))

To adjust the point size based on the population (pop) of each country we can use:

Input
ggplot(gapminder_2007) +
geom_point(aes(x = gdpPercap, y = lifeExp,
size = pop))

We see that the point sizes in the plot above do not clearly reflect the population differences in each country. If we compare the point size representing a population of 250 million people with the one displaying 750 million, we can see, that their sizes are not proportional. Instead, the point sizes are binned by default. To reflect the actual population differences by the point size we can use the scale_size_area() function instead. The scaling information can be added like any other ggplot object with the + operator:

Input
ggplot(gapminder_2007) +
geom_point(aes(x = gdpPercap, y = lifeExp,
size = pop)) +
scale_size_area(max_size = 10)

Note that we have adjusted the point’s max_size which results in bigger point sizes.