Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plotSidebars

Plot Table as Horizontal Sidebars


Description

Plot (x,y) table (matrix or data frame) as horizontal sidebars.

Usage

plotSidebars(z, scale = 1, col = lucent("blue", 0.25), ...)

Arguments

z

data frame or matrix of z-values (e.g., age frequencies) where rows form the plot's y-values and columns describe the grouping variable along the x-axis.

scale

numeric scale factor controlling the leftward expansion of z-value bars.

col

colour to fill bars.

...

additional parameters used by par and polygon. The user can also pass in two non-formal arguments to control the function:
lbl – labels for the x- and y-axis;
margin – function to report margin summaries.

Details

Plots z-data as horizontal bars arising from an x-coordinate controlled by the column names of z. The bars extend left along the y-coordinate by z*scale from the central x-coordinate.

Author(s)

Steve Martell, International Pacific Halibut Commission, Seattle WA

See Also

Examples

local(envir=.PBSmodEnv,expr={
  oldpar = par(no.readonly=TRUE)
  pbsfun = function () {
    meanmarg = function(x){x=x[!is.na(x)]; 
      if (length(x)==0 | all(x==0)) NA else sum((x/sum(x))*as.numeric(names(x)))}
    data(CCA.qbr,envir=.PBSmodEnv)
    plotSidebars(CCA.qbr,scale=4,las=1,border="navyblue",mar=c(4,4,1,1),
      lbl=c("Year","Quillback Rockfish Age"),margin=function(x){round(meanmarg(x),0)})
    invisible() }
  pbsfun()
  par(oldpar)
})

PBSmodelling

GUI Tools Made Easy: Interact with Models and Explore Data

v2.68.8
GPL (>= 2)
Authors
Jon T. Schnute [aut], Alex Couture-Beil [aut], Rowan Haigh [aut, cre], Nicholas Boers [ctb], Anisa Egeli [ctb], A. R. Kronlund [ctb], Steve Martell [ctb], Norm Olsen [ctb]
Initial release
2019-03-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.