Putting the x-axis on a log scale
You previously created a scatter plot with population on the x-axis and life expectancy on the y-axis. Since population is spread over several orders of magnitude, with some countries having a much higher population than others, it's a good idea to put the x-axis on a log scale.
This exercise is part of the course
Introduction to the Tidyverse
Exercise instructions
- Change the existing scatter plot (code provided) to put the x-axis (representing population) on a log scale.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
library(gapminder)
library(dplyr)
library(ggplot2)
gapminder_1952 <- gapminder %>%
filter(year == 1952)
# Change this plot to put the x-axis on a log scale
ggplot(gapminder_1952, aes(x = pop, y = lifeExp)) +
geom_point()