createFactorMap: create the base plot maps for CA type graphs with 'ggplot2'.

View source: R/CreateFactorMaps4CA.R

createFactorMapR Documentation

create the base plot maps for CA type graphs with ggplot2.

Description

createFactorMap: Creates the ggplot2 basic factor maps for CA type graphs. The final maps are created by using overlays on top of the base map.

A map for CA is created with the baseMap to which is added text/dot map. createFactorMap calls the functions map4DotsAndLabels and createBaseMap.

Usage

createFactorMap(
  X,
  axis1 = 1,
  axis2 = 2,
  constraints = NULL,
  title = NULL,
  col.points = "blueviolet",
  alpha.points = 0.5,
  display.points = TRUE,
  pch = 19,
  cex = 2.5,
  display.labels = TRUE,
  col.labels = "darkorchid4",
  alpha.labels = 1,
  text.cex = 4,
  font.face = "bold",
  font.family = "sans",
  col.axes = "darkorchid",
  alpha.axes = 0.2,
  width.axes = 1.1,
  col.background = adjustcolor("lavender", alpha.f = 0.2),
  force = 1,
  segment.size = 0,
  ...
)

Arguments

X

the factor scores to plot.

axis1

the column of X used for the horizontal axis of the plot. Default = 1.

axis2

the column of X used for the vertical axis of the plot. Default = 2.

constraints

a list with minx miny maxx maxy, typically obtained from ExPosition. If NULL (default) it is computed with the function prettyGraphs::minmaxHelper().

title

A title for the graph. Default is NULL.

col.points

the color of the points/dots. Can be one color or a vector of colors. If a vector, it needs to have exactly the number of items to be plotted. Default = 'blueviolet'.

alpha.points

(default = .5), the alpha (transparency) for the points, should be between 1 (opaque) and 0 (completely transparent).

display.points

if TRUE (Default) create the map for the points.

pch

the character for the points, Default is 19 (circles).

cex

size of the dots. Default = 2.5

display.labels

if TRUE (Default), create the map for the labels.

col.labels

the color of the labels Can be one color or a vector of colors. If a vector it needs to have exactly the number of items to be plotted. Default = 'darkorchid'.

alpha.labels

(default = 1), the alpha (transparency) for the points, should be between 1 (no transparency) and 0 (completely transparent).

text.cex

= 4, font size for labels.

font.face

(Default = 'bold') font for labels.

font.family

(Default = 'sans') font family for labels.

col.axes

color for the axes, default is 'darkorchid'.

alpha.axes

alpha parameter (transparency) for the axes, default is .2.

width.axes

the width of the axes, default is 1.1.

col.background

the color theme of the background, default is adjustcolor('lavender', alpha.f = .2).

force

(default = 1). How much ggrepel repels the label

segment.size

(default = 0) size of segment line for ggrpel.

...

stuff to be passed to other functions.

Value

a list with 6 elements:

  1. zeMap: The Complete Map (background Dots and Labels);

  2. zeMap_background: The Background;

  3. zeMap_dots:: The dots;

  4. zeMap_text:: The Labels;

  5. factorScores:: The factor scores; and

  6. constraints:: The list of the contraints'

Important_Note

When creating multiple layers graphs, because of the way ggplot2 create graphs, all the matrices/dataframe should all the have the same column names [e.g., colnames() equal to c("Dimension 1", "Dimension 2")]. When it is not the case, some strange and cryptic error may be produced (e.g., "cannot find Dimension").

Author(s)

Hervé Abdi

See Also

map4DotsAndLabels createBaseMap .


HerveAbdi/PTCA4CATA documentation built on July 17, 2022, 5:41 a.m.