Exercise

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.

Instructions 1/4

undefined XP
    1
    2
    3
    4

Clean up the theme:

  • Add a classic theme to the plot with theme_classic().
  • Set axis.line.y, axis.ticks.y, and axis.title to element_blank().
  • Set the axis.text color to "black".
  • Remove the legend by setting legend.position to "none".