Learn R Programming

WVPlots (version 1.3.7)

ScatterHistC: Plot a conditional scatter plot with marginals.

Description

Plot a scatter plot conditioned on a discrete variable, with marginal conditional density plots.

Usage

ScatterHistC(
  frame,
  xvar,
  yvar,
  cvar,
  title,
  ...,
  annot_size = 3,
  colorPalette = "Dark2",
  adjust_x = 1,
  adjust_y = 1
)

Value

plot grid

Arguments

frame

data frame to get values from

xvar

name of the x variable

yvar

name of the y variable

cvar

name of condition variable

title

title to place on plot

...

no unnamed argument, added to force named binding of later arguments.

annot_size

numeric scale annotation text (if present)

colorPalette

name of a Brewer palette (see https://colorbrewer2.org/ )

adjust_x

numeric: adjust x density plot

adjust_y

numeric: adjust y density plot

Details

xvar and yvar are the coordinates of the points, and cvar is the discrete conditioning variable that indicates which category each point (x,y) belongs to.

See Also

ScatterHist

Examples

Run this code

if (requireNamespace('data.table', quietly = TRUE)) {
	# don't multi-thread during CRAN checks
		data.table::setDTthreads(1)
}

set.seed(34903490)
frm = data.frame(x=rnorm(50),y=rnorm(50))
frm$cat <- frm$x+frm$y>0
WVPlots::ScatterHistC(frm, "x", "y", "cat",
                      title="Example Conditional Distribution")

Run the code above in your browser using DataLab