Lesson 27 of 43
In Progress

Use Color in Titles to Highlight Findings

Your Turn

Use color in your title to highlight your main finding. You’ll need to:

  1. Add HTML in the labs() function to add the title
  2. Change the plot.title argument in the theme() function so that it interprets the HTML correctly

Learn More

If you want to read about everything the ggtext package can do, here’s its documentation website. The package’s author, Claus Wilke, also gave a talk at rstudio::conf 2020 about it.

Hopefully I’ve convinced you that you don’t need to know much HTML in order to use the ggtext package. If you do want to learn a bit more, the HTML tutorials on W3schools.com are a great place to start. Here’s the page on the span tag if you just want to check that out.

If you want to see the the list of named colors in R, it’s here. All named colors in R should also work in HTML. So, for example, if you have a line that is blue, adding <span style='color: blue'>Title Text</span> will make your title that same shade of blue.

Questions about the lesson? Put them below.

    1. Yes, it should. All the HTML code does is change the figure produced by ggplot. That figure is then displayed as a PNG image in PDF/Word so it should work. Let me know if it doesn’t work for you for some reason!

  1. HI David should this plot.title be this: plot.title = element_markdown(face = “bold”)) + , we need to change it to element_markdown and also put the second brackets after bold.

    On your solutions code you have this: plot.title = element_text(face = “bold”) +

    Please confirm – unless ofcourse it worked on your machine.