Learn R Programming

statisR (version 1.0.1)

plot.statis.dual.circle: Bivariate PCA-style Scatter Plot

Description

This function generates a 2D scatter plot with support for multiple groups, labels, arrows from the origin, reference circles, cross axes, and full style customization using ggplot2.

Usage

# S3 method for statis.dual.circle
plot(
  points.list,
  style.points = list(list(size = 3)),
  style.circle = list(),
  radius.circle = 1,
  labels = "auto",
  labels.style = NULL,
  draw.labels = TRUE,
  vars.direction = NULL,
  style.vars = list(),
  radius.vars = c(0.5, 1),
  join.dots = FALSE,
  style.join = list(),
  base.colors = .base.colors,
  axes = TRUE,
  frame = TRUE,
  hide.ticks = TRUE,
  proportion = 1,
  xlim = NULL,
  ylim = NULL,
  axes.xy = TRUE,
  style.axes.xy = list(linewidth = 0.35, linetype = "dashed", color = "gray40"),
  arrows.points = TRUE,
  factor.arrow = 0.95,
  style.arrows = list(color = "red", linewidth = 0.6, arrow = grid::arrow(length =
    grid::unit(0.2, "cm")))
)

Value

A ggplot object with the generated plot.

Arguments

points.list

List of numeric objects (matrices, data.frames, or lists of vectors), each representing a group of 2D points.

style.points

List of ggplot2 styles applied per group. If NULL, geom_point() is used by default.

style.circle

List of styles for the reference circle (passed to ggforce::geom_circle).

radius.circle

Radius (or vector of radii) to draw circles centered at the origin. Default value 1, if 0, no circles are drawn.

labels

"auto" generates numeric labels by group, or it can be a vector/list of custom labels.

labels.style

List of styles for the labels, passed to ggrepel::geom_text_repel.

draw.labels

Logical. If TRUE, labels are drawn on the points.

vars.direction

Directions of projected variables.

style.vars

Style for projected variables.

radius.vars

Radii used to scale variable arrows.

join.dots

Logical or list. If TRUE, connects points by group. If a list, connects points as manually defined.

style.join

List of styles for connecting points (passed to geom_path()).

base.colors

Vector of base colors used for the groups.

axes

Logical. If FALSE, all axis elements are removed.

frame

Logical. Not directly used; may be reserved for future use.

hide.ticks

Logical. If TRUE, hides axis ticks and text.

proportion

Fixed aspect ratio of the plot (to avoid distortion).

xlim

X-axis limits.

ylim

Y-axis limits.

axes.xy

Logical. If TRUE, draws cross axes (X = 0, Y = 0) with defined style.

style.axes.xy

List of styles for the XY cross axes (e.g., linetype, color, etc.).

arrows.points

Logical. If TRUE, draws arrows from the origin to each point.

factor.arrow

Factor to shorten the arrows.

style.arrows

List of styles for the arrows.

See Also

statis.dual

Examples

Run this code
data(Tuis5_95, Tuis5_96, Tuis5_97, Tuis5_98)
labels <- c("95","96","97","98")

res <- statis.dual(list(Tuis5_95, Tuis5_96, Tuis5_97, Tuis5_98), labels.tables = labels)

# Interstructure
t <- ggplot2::ggtitle("Interstructure")
plot.statis.dual.circle(points.list = list(res$interstructure), labels = res$labels.tables) + t

# Circle of correlations (all variables)
t <- ggplot2::ggtitle("Correlation (all variables)")
plot.statis.dual.circle(list(res$supervariables), labels = row.names(res$supervariables)) + t

# Circle of correlations (variables selected)
selected.variables <- c("Ph", "Temp", "DBO", "ST", "PO4", "NO3", "POD", "Cal")
superv.sel.df <- select.super.variables(res$supervariables, res$vars.names, selected.variables)

t <- ggplot2::ggtitle("Correlation (selected variables)")
plot.statis.dual.circle(list(superv.sel.df), labels = row.names(superv.sel.df)) + t

Run the code above in your browser using DataLab