ez.scatterplot: scatter plot with lattice

View source: R/plot.R

ez.scatterplotR Documentation

scatter plot with lattice

Description

scatter plot with lattice

Usage

ez.scatterplot(
  df,
  cmd,
  lmline = TRUE,
  loess = FALSE,
  model = c("lm", "lmrob", "lmRob", "rlm"),
  type = c("spartial", "partial"),
  scale = FALSE,
  rp = TRUE,
  rp.x = 0.025,
  rp.y = 0.05,
  se = TRUE,
  layout = NULL,
  rp.size = 14,
  line.width = 3,
  point.size = 14,
  x.axis.size = 16,
  y.axis.size = 16,
  x.lab.size = 18,
  y.lab.size = 18,
  title.size = 20,
  legend.size = c(0, 14),
  line.color = "#BE1B22",
  line.style = 1,
  loess.color = "dark grey",
  loess.width = 3,
  loess.style = 2,
  point.color = "#0086B8",
  point.shape = 16,
  point.alpha = 0.9,
  colors = ez.palette("Zhu"),
  shapes = c(16, 17, 15, 3, 7, 8),
  ylab = NULL,
  xlab = NULL,
  xbreaks = NULL,
  ybreaks = NULL,
  xlimits = NULL,
  ylimits = NULL,
  title = NULL,
  zlab = NULL,
  legend.box = FALSE,
  legend.position = "top",
  legend.direction = "horizontal",
  hack = FALSE,
  print2scr = TRUE,
  ...
)

Arguments

df

data frame

cmd

like "y~x+a+b", "y~x+a+b|z", "y~x+a+b||z", "y~x+a+b|||z"where y x are continous, z discrete (| one regression line, || multiple regression lines by levels of z–gives interaction p value), +a+b optional for covariates residualization
y~x+a+b|||z plots separated by z groups, y~x+a+b||||z plots with and without z grouping

lmline

T/R lmline (for all data points), particularlly useful when separate lines are plotted for each group

loess

T/R adds a loess fit (uses panel.loess, the same as type = c("smooth"))

model

one of c('lm', 'lmrob', 'lmRob', 'rlm'), robustbase::lmrob–MM-type Estimators; robust::lmRob–automatically chooses an appropriate algorithm. one or more, 'lm' will always be included internally, even if not specified

type

one of c('partial','spartial'), or c('p','sp'), plot partial or semi-partial correlation. Only applicable when covar exists

scale

when having covariates, z transform residuals

rp

show r (signed) and p values

rp.x

r p values x position (0-1, relative to top left, big–>right), ignored if rp=FALSE.

rp.y

r p values y position (0-1, relative to top left, big–>up), ignored if rp=FALSE.

se

standard error of linear regression line

rp.size

r p values font size, ignored if rp=FALSE

point.size

if less point, one can increase size

legend.size

c(0,12) the first number 0 controls the legend title, 0=hide; the second number controls legend.key.size, legend.text

line.color

only applicable when not auto varied, regression line color.

point.color

only applicable when not auto varied

point.shape

only applicable when not auto varied

point.alpha

if overplot for points, one can reduce alpha

ylab

y label. NULL

xlab

x label. NULL

xbreaks

seq(from=95, by=0.25, to=97). xbreaks does not require xlimits set

xlimits

c(0,1). xlimits does not require xbreaks set

zlab

z legend label/title, only applicable when there is z provided. NULL

legend.box

box of legend, T or F

legend.position

legend position 'none' (I think this is not natively supported, but works) "left", "right", "top", and "bottom"
c(x,y,two-element fractional numeric vector) c(0,0) corresponds to the "bottom left" and c(1,1) corresponds to the "top right" position, but within the plot box.

legend.direction

horizontal or vertical

hack

T/F if more than 1 model specified, plot all in one plot

...

other parameters passed to xyplot. E.g.,
jitter.x=T, jitter.y=T, factor=1, amount=NULL see jitter
layout=c(col,row)–a bit weird. lattice orders panels from the bottom up. To get what you want either use as.table = TRUE or reverse the ordering in index.cond. eg, as.table=F, index.cond=list(c(3,2,1))

Value

a lattice plot, can use update() to change the plot

Note

specify auto through param colors, shapes


jerryzhujian9/zmisc documentation built on March 9, 2024, 12:49 a.m.