ScatterPlot: ScatterPlot

Description Usage Arguments Details Value Examples

View source: R/ScatterPlot.R

Description

Draws scatter plots.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
ScatterPlot(
  x,
  y,
  points_labs = NULL,
  createWindow = FALSE,
  main = NULL,
  color = NULL,
  pch = NULL,
  size = 1,
  cex.lab = 3,
  xlab = NULL,
  ylab = NULL,
  legend_pch = NULL,
  legend_color = NULL,
  drawEllipses = FALSE,
  typeEl = "norm",
  levelEl = 0.9
)

Arguments

x

x-axis values.

y

y-axis values.

points_labs

If not NULL, will show the labels for each observation on the plot.

createWindow

If TRUE, will create a new window for the plot.

main

Plot title. If NULL, default title is provided.

color

Optional character, factor or numeric vector giving the color of the observations. If length(color) = 1, the unique color is kept for all the points.

pch

Optional character, factor or numeric vector giving the pch of the observations.

size

The points size.

cex.lab

The size of points labels.

xlab

If not NULL, label for the x-axis.

ylab

If not NULL, label for the y-axis.

legend_pch

If not NULL, the labels for the pch legend.

legend_color

If not NULL, the labels for the color legend.

drawEllipses

If TRUE, will draw ellipses with the ggplot2::stat_ellipse with groups coresponding to the color vector.

typeEl

The type of ellipse, either "norm" (multivariate normal distribution), "t" (multivariate t-distribution) and "euclid" draws a circle with the radius equal to level, representing the euclidean distance from the center.

levelEl

The confidence level at which to draw an ellipse.

Details

If type.obj is 'OPLSDA', axes = 1 represents the predictive score vector, axes = 2 represents the first orthogonal score vector, etc.

Value

A score or loading plot in the current device.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
x <- c(1:20)
y <- sample(20)
colors <- c(rep(1,10), rep(2,10))
points_pch <-  c(rep(17,10), rep(18,10))
labels <- as.character(c(1:20))
# automatic legend names and values assignment
ScatterPlot(x = x, y = y, points_labs = labels, createWindow=FALSE,
           main = 'Scatter plot', color = colors, pch = points_pch,
           xlab = "x axis", ylab = "y axis")

# decide on the color or pch values
legend_color = c(rep("A", 10), rep("B", 10))
legend_pch = c(rep("C", 10), rep("D", 10))
ScatterPlot(x = x, y = y, points_labs=labels, createWindow=FALSE,
           main = 'Scatter plot', color = colors, pch = points_pch,
           xlab = "x axis", ylab = "y axis",
           legend_pch = legend_pch,legend_color=legend_color)

ManonMartin/MBXUCL documentation built on Nov. 26, 2021, 8:45 p.m.