plotStackedBarplot: Plot annual stacked bar plot

plotStackedBarplotR Documentation

Plot annual stacked bar plot

Description

This function will plot a stacked bar plot that has negative and positive values. It also has the option to plot the average of values provided.

Usage

plotStackedBarplot(
  x,
  y,
  z,
  zsc,
  plotAverage = TRUE,
  ylab1 = NULL,
  ylab2 = NULL,
  xaxtlabels = TRUE,
  ylim1,
  ylim2,
  ncol = 1,
  hclpalette = "Viridis",
  legendLocation = "inside",
  legendInset = c(-0.38, 0),
  plotScorecard = FALSE,
  scorecardLines = TRUE,
  scorecardLabels = TRUE,
  scorecardSeparation = par("cin")[2],
  scorecardWidth = par("cin")[2]
)

Arguments

x

a vector indicating what the columns represent for z

y

a vector indicating what the rows represent for z

z

a matrix with the columns being the x-axis and the rows being items that wish to be stacked.

zsc

a vector of normalized values of z for the scorecard, ignored if plotScorecard = FALSE

plotAverage

a logical value indicating whether or not to add the average value from matrix z.

ylab1

name for the y-axis on side 2, default is NULL

ylab2

name for the y-axis on side 4 if plotAverage = TRUE, ignored otherwise, default is NULL.

ylim1

limits for the y-axis on side 2, if not supplied, it will be inferred from z

ylim2

limits for the y-axis on side 4 if plotAverage = TRUE, ignored otherwise. If not supplied, it will be inferred from the data.

ncol

supplied to legend, the number of columns in which to set the legend items, default is 1.

hclpalette

Name of an hcl.colors palette. Names can be found by doing hcl.pals(), default is a sequential palette, 'Viridis'.

legendLocation

Character string, valid choices are inside or outside. Indicating if the legend should be place inside the plot window (default), or outside of the plot window on the right hand side.

legendInset

Vector of two values to control placement of legend, see ?legend for details, when legendLocation = 'outside'.

plotScorecard

Logical indicating whether or not to plot scorecard on side = 1.

scorecardLines

Logical indicating whether or not to put vertical lines on scorecard.

scorecardLabels

Logical indicating whether or not to print ysc values in scorecard.

scorecardSeparation

Value used to denote the separation between the main plot and scorecard. Suggested to use par('cin')[2] (default) and play with that value. If closer is desired, decrease.

scorecardWidth

Value used to denote the width of the scorecard. Suggested to use par('cin')[2] (default) and play with that value. If wider is desired, increase.

xlabels

Logical indicating if the x-axis ticks should be annotated.

Author(s)

Chantelle Layton


clayton33/csasMarPhys documentation built on June 8, 2025, 3:10 a.m.