PrettyBarPlot2: a 'ggplot2'-based function to plot bar plots for a series of...

View source: R/PrettyBarPlot2.R

PrettyBarPlot2R Documentation

a ggplot2-based function to plot bar plots for a series of variables: Used for plotting bootstrap ratios or contributions for PCA, CA, MCA, PLS, etc.

Description

PrettyBarPlot2: a ggplot2-based version of PrettybarPlot and PrettyBarPlotColor. PrettyBarPlot2 creates bar plots for a set of items (e.g., observations or variables) analyzed with multivariate methods such as PCA, CA, MCA, PLS etc. PrettyBarPlot2 is used to display the bootstrap ratios or contributions plots for CA/MCA/PCA/PLS. Significant or important items are plotted in color, non-significant (or un-important) items are plotted in gray.

Usage

PrettyBarPlot2(
  bootratio,
  font.size = NULL,
  threshold = 3,
  ylim = NULL,
  color.bar = c("lavender", "darkolivegreen3", "gray90"),
  color.bord = c("mediumpurple4", "darkolivegreen4", "gray75"),
  color.letter = c("mediumpurple4", "darkolivegreen4", "gray75"),
  color4ns = "gray75",
  color4bar = NULL,
  plotnames = TRUE,
  main = NULL,
  ylab = NULL,
  sortValues = FALSE,
  signifOnly = FALSE,
  horizontal = TRUE,
  angle.text = if (horizontal) {
     90
 } else {
     0
 },
  abbreviate_labels = FALSE,
  make_labels_into_paragraphs = FALSE,
  font.shrink = 1,
  line.col = "red",
  line.type = 2,
  line.size = 0.5,
  line.alpha = 0.5
)

Arguments

bootratio

the bootstrap ratios (BR) or contributions or similar statistics to be plotted. (e.g., obtained from Boot4PTCA).

font.size

(Default: NULL) the font size to write the name of the item. When NULL, font.size = 1.

threshold

(Default: 2) The critical value for significance which matches a p < .05 significance level. The |BR| < threshold are plotted in gray, the other BR are plotted in colors.

ylim

(Default: NULL) a 2-element vector giving min and max for the y-axis; when NULL (default) set to c(-max(abs(y)), max(abs(y)))

color.bar

a 3-element vector of color names for the bars for (respectively) significant positive, significant negative, and non-significant. Default is c('lavender','darkolivegreen3','gray90').

color.bord

The color for the border of the bars, Default: c("mediumpurple4", "darkolivegreen4", "gray75").

color.letter

a 3-element vector of color names for the names of the items for (respectively) significant positive, significant negative, and non-significant. Default is c("mediumpurple4",'darkolivegreen4','gray75')

color4ns

(Default: 'gray75') color for the non-significant bootratio.

color4bar

(Default: NULL) a vector of color names (same dimension as bootratio). Needs to be either a name from the set colors() or in hex format.

plotnames

if codeTRUE (default) write the names of the items.

main

(default is NULL) a title for the graph.

ylab

(default is NULL) a label for the y axis (i.e., BR). If NULL ylab = 'Bootstrap ratios'.

sortValues

(Default: FALSE) when TRUE sort the values to plot.

signifOnly

(Default: FALSE) when TRUE plot only the significant values.

horizontal

(Default: TRUE) when TRUE, the plot is horizontal, when FALSE the plot is vertical.

angle.text

(Default: 90, i.e., so slant) the "slanting factor" for the text.

abbreviate_labels

(Default: FALSE).

make_labels_into_paragraphs

(Default: FALSE).

font.shrink

(default = 1): a proportion for how much the non-significant font shrinks.

line.col

(Default = 'red') the color for significance for the critical value line.

line.type

The type of line for the critical line (Default = 2, a dashed line).

line.size

(Default = .5 ), the thickness of the critical line.

line.alpha

(Default = .5 ), the transparency of the critical line (0 = all transparent, 1 = opaque).

Details

Note that this version is still in development. Current version generates a (strange) warning message from ggplot2 about element_text().

PrettyBarPlot2 integrates PrettyBarPlot and PrettyBarPlotColors.

Value

A ggplot2 object containg the graph (i.e., to be plotted with print).

Author(s)

Vincent Guillemot & Hervé Abdi

See Also

PrettyBarPlot PrettyBarPlotColor PrettyBarPlotColor4Q

Examples

toto <- 8*(.5 - runif(7))
names(toto) <- paste0('V', 1:7)
PrettyBarPlot2(toto)

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