BG: Add background color to a plot

Description Usage Arguments See Also Examples

View source: R/BG.R

Description

Overlays a colored rectangle over the entire plotting region.

Usage

1
BG(col = openintro::COL[5, 9])

Arguments

col

Color to overlay.

See Also

COL

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Test <- function(col) {
  plot(1:7, col = COL[1:7], pch = 19, cex = 5,
      xlim = c(0, 8),
      ylim = c(0, 9))
  BG(col)
  points(2:8, col = COL[1:7], pch = 19, cex = 5)
  text(2, 6, "Correct Color")
  text(6, 2, "Affected Color")
}

par(mfrow = c(2, 2))

# Works well since black color almost fully transparent
Test(COL[5, 9])

# Works less well since transparency isn't as significant
Test(COL[5, 6])

# Pretty ugly due to overlay
Test(COL[5, 3])

# Basically useless due to heavy color gradient
Test(COL[4, 2])

OpenIntroStat/openintro-r-package documentation built on Jan. 22, 2020, 3:23 p.m.