Textual Healing

November 14, 2012

(This article was first published on is.R(), and kindly contributed to R-bloggers)

While I know there are several awesome guides for how to make fine-tuning adjustments to plot labels/axes/ticks/text in ggplot, this is still the most common question I get from people new to ggplot: how do I change the size/font/color/position of (some text element)? Here are some examples. 

First, let’s load the made-up data from yesterday.

Our default plot looks like this:

#Adjust X Axis Label Size/Face/Color:

Plot.1 + theme(axis.title.x = element_text(face=”bold”, 


                                           size=14) )

To Adjust Y Axis Label Size/Face/Color:

Plot.1 + theme(axis.title.y = element_text(face=”italic”, 


                                           size=24) )

When adjusting multiple parameters, you can use specify both within the “theme” command:

Plot.1 + theme(axis.title.x = element_text(face=”bold”, 



               axis.title.y = element_text(face=”italic”, 


                                           size=24) )

Changing Main Title Text/Face/Color  

Plot.1 + theme(plot.title = element_text(family=”sans”,



                                           size=44) )

When modifying the text in the legend, you can adjust either the legend title text…

Plot.1  + theme(legend.title = element_text(colour=”dodgerblue”, 



…or the text for the legend labels:

Plot.1 + theme(legend.text = element_text(colour=”goldenrod4”, 

                                          size = 18, 

                                          face = “italic”))

Or by doing both simultaneously:

Plot.1 + theme(legend.title = element_text(colour=”dodgerblue”, 



               legend.text = element_text(colour=”goldenrod4”, 

                                          size = 18, 

                                          face = “italic”))

Another option in the element_text() is angle, which is useful in certain occasions, especially when you have tight axis tick labels:

These can be adjusted using the angle command for the axis.text.x element:

Plot.1  + theme(axis.text.x = element_text(colour=”black”, 

                                           size = 11, 

                                           face = “bold.italic”,




Tomorrow’s Post will show how to adjust the facet strips…stay tuned! Full code/script appears below:

To leave a comment for the author, please follow the link and comment on their blog: is.R().

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , ,

Comments are closed.


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training



CRC R books series

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)