rect: Draw Rectangles

Description Usage Arguments Details Value Examples

Description

Possibly filled rectangles

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
rect(xleft, ybottom, ...)

## S4 method for signature 'numeric,numeric'
rect(
  xleft,
  ybottom,
  ...,
  border = colour,
  colour = color,
  color = NULL,
  col = fill,
  fill = NA
)

## S4 method for signature 'xy,xy'
rect(xleft, ybottom, ...)

## S4 method for signature 'xy,missing'
rect(xleft, ybottom, ...)

Arguments

xleft

spedifier for the bottom left corner

ybottom

spedifier for the top right corner

...

additional arguments, as for rect

border

colour, as for rect

colour, color

alternative names for border

col

colour, as for rect

fill

alternative name for col

Details

The primary function in the graphics package requiers the corners of the rectangle to be specified by four separate real numbers. This interface allows the corners, in addition, to be specified by two "xy" specifiers for the opposite corners, or single "xy" object to specify both. See the example for a typical case.

Value

as for rect

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
bluish <- alpha("sky blue", 0.5)
curve(dnorm, xlim = c(-4,4), n = 1000,  ## establish the plotting coordinate system
      xlab = expression(italic(z)),
      ylab = expression(phi(italic(z))))
corners <- complex(real = par("usr")[1:2], imaginary = par("usr")[3:4])
rect(corners, fill = bluish, colour = bluish)
curve(dnorm, xlim = c(-4, 4), n = 1000, add = TRUE, col = "red")
abline(h = 0, v = 0, lty = "dashed")
z <- c(1.96, seq(1.96, 4, length.out = 500))
z <- complex(real = z, imaginary = c(0, dnorm(z)))
polygon(z, density = 15, angle = -45, colour = "red")
arrows(3, 0.05, 2.5, dnorm(2.5)*0.4, length = 2, gap = 2)
text(3, 0.05, expression(area == alpha/2), pos = 3, cex = 0.8, offset = 0)
Re(z) <- -Re(z)
polygon(z, density = 15, angle = 45, colour = "red")
arrows(3, 0.05, 2.5, dnorm(2.5)*0.4, length = 2, gap = 2)
text(-3, 0.05, expression(area == alpha/2), pos = 3, cex = 0.8, offset = 0)
arrows(-3, 0.05, -2.5, dnorm(-2.5)*0.4, length = 2, gap = 2)
text(-1.25, 0.05, expression(zeta[  alpha/2] == -zeta[1-alpha/2]), pos = 3, offset = 0)
arrows(-1.25, 0.05, -1.96, 0, length = 2, gap = 2)
text( 1.25, 0.05, expression(zeta[1-alpha/2]), pos = 3, offset = 0)
arrows( 1.25, 0.05,  1.96, 0, length = 2, gap = 2)
text("top left",
  expression(phi(italic(z)) == frac(exp(-italic(z)^2/2), sqrt(2*pi))), cex = 0.8)
text("top right",
  expression(Phi(z) == integral(phi(italic(t))*italic(dt), -infinity, z)))

BillVenables/WWRGraphics documentation built on Feb. 1, 2021, 12:13 p.m.