Get access to all lessons in this course.
-
Advanced Data Wrangling and Analysis
- Overview
- Importing Data
- Tidy Data
- Reshaping Data
- Dealing with Missing Data
- Changing Variable Types
- Advanced Variable Creation
- Advanced Summarizing
- Binding Data Frames
- Functions
- Merging Data
- Renaming Variables
- Quick Interlude to Reorganize our Code
- Exporting Data
-
Advanced Data Visualization
- Data Visualization Best Practices
- Tidy Data
- Pipe Data Into ggplot
- Reorder Plots to Highlight Findings
- Line Charts
- Use Color to Highlight Findings
- Declutter
- Use the scales Package for Nicely Formatted Values
- Use Direct Labeling
- Use Axis Text Wisely
- Use Titles to Highlight Findings
- Use Color in Titles to Highlight Findings
- Use Annotations to Explain
- Tweak Spacing
- Customize Your Theme
- Customize Your Fonts
- Try New Plot Types
-
Advanced RMarkdown
- Advanced Markdown Text Formatting
- Tables
- Advanced YAML
- Inline R Code
- Making Your Reports Shine: Word Edition
- Making Your Reports Shine: HTML Edition
- Making Your Reports Shine: PDF Edition
- Presentations
- Dashboards
- Other Formats
-
Wrapping Up
- You Did It!
Going Deeper with R
Use Color in Titles to Highlight Findings
This lesson is locked
This lesson is called Use Color in Titles to Highlight Findings, part of the Going Deeper with R course. This lesson is called Use Color in Titles to Highlight Findings, part of the Going Deeper with R course.
Transcript
Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.
Your Turn
Use color in your title to highlight your main finding. You’ll need to:
Add HTML in the
labs()
function to add the titleChange the
plot.title
argument in thetheme()
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.
You need to be signed-in to comment on this post. Login.
Abby Isaacson
May 17, 2021
Does this html code work to change colors/lines in PDF and Word output as well?
David Keyes
May 17, 2021
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!
Harold Stanislaw
May 20, 2021
Made the school name bold (as well as colored) by adding to the html.
David Keyes
May 21, 2021
Cool! I know only there are only a few html tags that do anything, but sounds like bolding is one!
Atlang Mompe
June 24, 2021
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.
David Keyes
June 25, 2021
Sorry, that was a typo! Fixed now.
David Keyes
January 14, 2022
Yep! I usually use a default theme like theme_ipsum() and add some customizations using the theme() function.
Elijah Phillips
November 30, 2022
I get "could not find function 'element_markdown'". I have loaded tidyverse and scales. I even tried copying and pasting to code from the solution...
Elijah Phillips
November 30, 2022
Nevermind, I didn't install ggtext
Hatem Kotb
January 15, 2023
Had the same issue & was about to go in circles. Thanks, haha! 😄