Specify font family of labels at a time in ggplot2


While opts() offers the way to specify font family for each text element,
theme(base_family=…) enables to set the font family of all text elements at a time.
The “default” can be overwritten by opts().

 

sans default:

qplot(1:10, 1:10, label=letters[1:10], colour=1:10, geom="text", main="sans family") + theme_grey(base_family="sans")


 

serif default:

qplot(1:10, 1:10, label=letters[1:10], colour=1:10, geom="text", main="serif family") + theme_grey(base_family="serif")

 

serif default but xlab is sans

qplot(1:10, 1:10, label=letters[1:10], colour=1:10, geom="text", main="serif family") + theme_grey(base_family="serif") +
  xlab("here is sans") + opts(axis.title.x=theme_text(family="sans"))

 

Note that font family in geom_text() is determined via different way, so theme_*(base_family) has no effect on geom_text().

4 thoughts on “Specify font family of labels at a time in ggplot2

  1. Howdy! This is kind of off topic but I need some guidance
    from an established blog. Is it tough to set up your own blog?
    I’m not very techincal but I can figure things out pretty fast. I’m
    thinking about setting up my own but I’m not sure where to begin. Do you have any points or suggestions? Thanks

  2. I really love your blog.. Excellent colors & theme.
    Did you develop this website yourself? Please reply back as I’m hoping to create my own website and want to learn where you got this from or exactly what the theme is called. Many thanks!

  3. My partner and I absolutely love your blog and find the majority of your post’s to be exactly I’m looking for.
    can you offer guest writers to write content in your case? I wouldn’t mind producing a post or elaborating on a number of the subjects you write concerning here. Again, awesome weblog!

    Recommended Reading
    Recommended Reading
    Recommended Reading

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s