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.
Questo esercizio fa parte del corso
Introduction to the Tidyverse
Istruzioni dell'esercizio
- Change the existing scatter plot (code provided) to put the x-axis (representing population) on a log scale.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
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()