Skip to content
R for the Rest of Us Logo

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window

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.

FYI, as you go through this lesson, I only begin to touch on working with the theme() function to customize plots, as I only really want to focus on teaching you how to remove things using element_blank(). However, there is a ton to learn here so definitely check out the Learn More section below!

Your Turn

Use some combination of:

Do the following:

  1. Remove gray background

  2. Remove axis titles

  3. Remove or minimize grid lines

Learn More

Editing ggplot theme elements can be confusing. You might consider checking out the ggeasy package, which aims to make doing common things much simpler.

Finally, if you’re confused by the idea of “complete” themes, the best description of them comes from the ggplot website:

These are complete themes which control all non-data display. Use theme() if you just need to tweak the display of an existing theme.

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Jodi Fender

Jodi Fender

May 11, 2021

I have a font I use for a project of mine (various from Whitney family), but it was stating font family not found in Windows font database. But...now every time I run the code for the new graph (not specifying any font) but using hrbrthemes/theme_ipsum I get, Warning (yellow triangle) font family not found in Windows font database font family not found in Windows font database font family not found in Windows font database font family not found in Windows font database font family not found in Windows font database font family not found in Windows font database font family not found in Windows font database font family not found in Windows font database

Jody Oconnor

Jody Oconnor

May 11, 2021

Missing font families came up in a previous lesson, but was put off for later. Now that we're back making charts pretty, I'd like to know how to access specific fonts (maybe this is covered in a later lesson...?)

When I run: theme(axis.title.x = element_blank(), axis.text = element_text(family = "ariel", size = 15),

within ggplot, I get a chart but the font seems to be the default still, and the error message shows at the top (regardless of the font name I include): Warning font family not found in Windows font database font family not found in Windows font database font family not found in Windows font database font family not found in Windows font database

Oindrila Bhattacharyya

Oindrila Bhattacharyya

May 13, 2021

When I try running library(ragg), it says "there is no package called 'ragg' ". Can you tell me why? Also I am getting the same error messages for font like others.

I was playing with hrbrthemes and was trying to manipulate the justification of the axis titles in theme_ipsum.
in the ?theme_ipsum Help file it returns: "axis_title_just axis title font justification, one of [blmcrt]"

?blmcrt said there’s not documentation. Googling blmcrt didn’t reveal anything. Setting axis_title_just = FALSE made it centered, not right justified. but the way [blmcrt] is shared in the help file, it seems like that refers to something fundamental that I should know.

I haven't been able to resolve the font issue yet. I have a Mac. I installed the Whitney font that someone mentioned above to test. I installed ragg and systemfont. I made sure to install Whitney to the computer and not just the user (which at first I thought was the problem). I can switch between fonts that were already installed like Georgia, Gill Sans, etc. But if i try theme_ipsum(base_family = "Whitney") I get the error:

Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : no font could be found for family "Whitney" Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : polygon edge not found

Hi could you please let me know whether my understanding here is correct?

  • We could use a combination of themes (eg: minimal, ipsum & custom/theme()). There is no limit. In that case, could this somehow cause conflict in some elements?
  • Standard themes like 'minimal' or 'classic' are not customizable in the function itself (eg: theme_minimal(axis.title = element_blank()) would throw an error.
  • Additional customization should be done in the 'custom' theme() function.
  • We can customize specific elements within the theme_ipsum() function, because it's not from the ggplot standard themes.

Jeremy Danz

Jeremy Danz

February 6, 2023

Hmm, any idea why when using theme_ipsum, and setting the axis_title_size = 0, it looks like the axis titles are still there, but just very very small?

When using theme_minimal and theme(axis.title = element_blank()) the axis titles appear gone completely.

Here's a screenshot of what I'm getting with theme_ipsum https://imgur.com/eZufC8N

I appear to be getting the same font issue that others are getting, which looks fixable, but also not particularly awful if it isn't fixed? everything seems to work still, it just throws an unpleasant looking error message?

thanks!

Zain Asaf

Zain Asaf

June 12, 2023

I have attempted to remove grid lines using the following line of code: pannel.grid.minor.y = element_blank()) However, I get the following error message: Error in mapply(): ! The pannel.grid.minor.y theme element is not defined in the element hierarchy.