ctext: Color text

Description Usage Arguments Examples

View source: R/plot_extra.R

Description

Add color to individual words in text functions. ctext, cmtext, and ctitle are analogous to text, mtext, and title, respectively. Note that title accepts some graphical parameters specific to the label type, e.g., col.main, but this is not implemented in ctitle–colors will be recycled if more than one label type is given. Similarly, further graphical parameters such as cex or line will be passed to all label types; see examples.

Usage

1
2
3
4
5
6
ctext(text, cols, space = TRUE, ...)

cmtext(text, cols, space = TRUE, ...)

ctitle(main = NULL, sub = NULL, xlab = NULL, ylab = NULL, cols,
  space = TRUE, ...)

Arguments

text

vector of text

cols

vector of colors; should be the same lenght as text or will me recycled with a warning

space

logical; if TRUE, adds space between text

...

additional parameters passed to text or mtext

main, sub, xlab, ylab

vector(s) of text for specific labels

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plot(1, ann = FALSE)
ctext(x = 1, y = 1, text = c('hello','little','point'), cols = 1:3, pos = 1)
cmtext(c('a','side','label'), 1:2, space = FALSE, side = 4, cex = 3)
cmtext(c('a','a','a'), 4:6, space = FALSE, side = 4, cex = 3, line = -2)

## note that line, cex, font, etc will be recycled
ctitle(main = c('the','main','label'), xlab = c('x','label'),
       ylab = c('y','label'), sub = c('sub', 'label'), col = 3:5)
ctitle(xlab = c('another','label'), ylab = c('another','label'),
       font = 3, col = 1:2, line = 2, cex = 1.5)

raredd/plotr documentation built on Nov. 13, 2018, 7:05 a.m.