Learn R Programming

broman (version 0.59-5)

grayplot: Plot with a gray background

Description

Like the plot function, but using a gray background just for the plot regin.

Usage

grayplot(x, y, ..., type = "p", hlines, hlines.col = "white",
  hlines.lty = 1, hlines.lwd = 1, vlines, vlines.col = "white",
  vlines.lty = 1, vlines.lwd = 1, xat, yat, bgcolor = "gray80",
  v_over_h = FALSE)

Arguments

x
Coordinates of points in the plot
y
Corrdinates of points in the plot (optional)
...
Optional graphics arguments
type
Plot type (points, lines, etc.)
hlines
Locations of horizontal grid lines; use hlines=NA to prevent horizontal grid lines
hlines.col
Colors of horizontal grid lines
hlines.lty
Line type of horizontal grid lines
hlines.lwd
Line width of horizontal grid lines
vlines
Locations of vertical grid lines; use vlines=NA to prevent vertical grid lines
vlines.col
Colors of vertical grid lines
vlines.lty
Line type of vertical grid lines
vlines.lwd
Line width of vertical grid lines
xat
Locations for x-axis labels; xat=NA indicates no labels
yat
Locations for y-axis labels; yat=NA indicates no labels
bgcolor
Background color
v_over_h
If TRUE, place vertical grid lines on top of the horizontal ones.

Value

  • None.

Details

Calls plot with type="n", then rect to get the background, and then points. Additional arguments you can include: mgp.x and mgp.y (like mgp, for controlling parameters of axis labels, but separate for x- and y-axis).

See Also

plot, par, rect, points

Examples

Run this code
set.seed(97536917)
x <- rnorm(100)
y <- x+rnorm(100, 0, 0.7)
grayplot(x, y, col="blue", pch=16)
at <- seq(-3, 3)
grayplot(x, y, col="blue", pch=16, hlines=at, vlines=at)
grayplot(x, col="violet", pch=16, bgcolor="gray90",
         hlines=seq(-4, 4, by=0.5), hlines.lwd=c(3,1),
         vlines=seq(0, 100, by=5), vlines.lwd=c(3,1,1,1))

Run the code above in your browser using DataLab