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

mat2pol

Plot columns of a matrix as stacked areas.


Description

matrix to polygon: Plot columns of a matrix as stacked areas.

Usage

mat2pol( pm,
       perm = 1:ncol(pm),
          x = as.numeric(rownames(pm)),
        col = rainbow(ncol(pm)),
         yl = 0:1,
     append = FALSE,
        ... )

Arguments

pm

Numerical matrix.

perm

integer vector of length ncol(pm), used to permute the columns of pm.

x

Numeric. The x-axis of the plot.

col

Colors of the areas.

yl

y-axis limits.

append

Logical. Should the polygons be added to an exiating plot

...

Further parameters passed to plot.

Details

The function is originally intended to plot stacked probabilities, hence the default of 0:1 for the y-axis.

Value

A matrix of ncol(pm)+1 columns with the first equal to 0, and the remaining the cumulative sum of the columns of pm[perm].

The function is called for its side effect - the stacked polygons.

Author(s)

Bendix Carstensen

Examples

M <- cbind( sort(runif(10)), sort(runif(10)), sort(runif(10)) )
pm <- sweep( M, 1, apply(M,1,sum), "/" )
mat2pol( pm )

Epi

Statistical Analysis in Epidemiology

v2.44
GPL-2
Authors
Bendix Carstensen [aut, cre], Martyn Plummer [aut], Esa Laara [ctb], Michael Hills [ctb]
Initial release
2021-02-28

We don't support your browser anymore

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