Setting colors for text elements – axis annotations, labels, plot titles, and legends

Axis annotations are the numerical or text values placed beside tick marks on an axis. Axis labels are the names or titles of axes, which tell the reader what the values on a particular axis represent. In this recipe, you will learn how to set the colors for these elements and legends.

Getting ready

All you need to try out this recipe is to run R and type the recipe in the command prompt. You can also choose to save the recipe as a script so that you can use it again later on.

How to do it...

Let's say that we want to make the axis value annotations black, the labels of the axes gray, and the plot title dark blue. For this, you should use the following code:

plot(rnorm(100), ...

Get R: Data Analysis and Visualization now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.