Aan de slagGa gratis aan de slag

Using annotate() for embellishments

In the previous exercise, we completed our basic plot. Now let's polish it by playing with the theme and adding annotations. In this exercise, you'll use annotate() to add text and a curve to the plot.

The following values have been calculated for you to assist with adding embellishments to the plot:

global_mean <- mean(gm2007_full$lifeExp)
x_start <- global_mean + 4
y_start <- 5.5
x_end <- global_mean
y_end <- 7.5

Our previous plot has been assigned to plt_country_vs_lifeExp.

Deze oefening maakt deel uit van de cursus

Introduction to Data Visualization with ggplot2

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Define the theme
plt_country_vs_lifeExp +
  ___() +
  theme(axis.line.y = ___,
        axis.ticks.y = ___,
        axis.text = ___(___),
        axis.title = ___,
        ___ = ___)
Code bewerken en uitvoeren