Learn R Programming

broman (version 0.84)

grayplot_na: Scatterplot with missing values indicated

Description

Scatterplot with a gray background and with points with missing values shown in separate panels near the margins.

Usage

grayplot_na(
  x,
  y = NULL,
  type = "p",
  bgcolor = "gray90",
  v_over_h = FALSE,
  pch = 21,
  bg = "lightblue",
  col = "black",
  force = c("none", "x", "y", "both"),
  ...
)

Value

None.

Arguments

x

Coordinates of points in the plot

y

Coordinates of points in the plot (optional)

type

Plot type (points, lines, etc.)

bgcolor

Background color

v_over_h

If TRUE, place vertical grid lines on top of the horizontal ones.

pch

point type

bg

Background color in points

col

Color of outer circle in points

force

Indicates whether to force the NA box (on the x-axis, y-axis, or both) even when there are no missing values.

...

Optional graphics arguments

Details

Calls plot() with `type="n", then graphics::rect() to get the background, and then graphics::points().

There are a bunch of hidden graphical arguments you can include: na.width controls the proportional width devoted to the NA boxes, and na.gap the proportion for the gap between the NA boxes and the main plot region. mgp.x and mgp.y (like mgp, for controlling parameters of axis labels, but separate for x- and y-axis). Also hlines to indicate locations of of horizontal gridlines, and hlines.col, hlines.lwd, and hlines.lty to set their color, width, and type. hlines=NA suppresses the grid lines. Similarly vlines, vlines.col, vlines.lwd, and vlines.lty. xat and yat are for specifying the locations of x- and y-axis labels, respectively. xat=NA and yat=NA indicate no labels.

See Also

grayplot(), dotplot()

Examples

Run this code
set.seed(97536917)
n <- 100
x <- rnorm(n)
y <- x+rnorm(n, 0, 0.7)
x[sample(n, 10)] <- NA

grayplot_na(x, y)

grayplot_na(x, y, force="y")

y[sample(n, 10)] <- NA
grayplot_na(x, y)

Run the code above in your browser using DataLab