PolygonNA: Plot a polygon by accounting for NA values (breaks in...

Description Usage Arguments Author(s) Examples

Description

This function is an improved version of polygon that considers NA values in plotting.

Usage

1
2
PolygonNA(x, lower, upper, 
    col = "grey")

Arguments

x

vector of x-values

lower

vector of lower polygon range

upper

vector of upper polygon range

col

color of the polygon

Author(s)

Matthias Forkel <matthias.forkel@tu-dresden.de> [aut, cre]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
x <- 1:10
med <- rnorm(length(x))
lower <- med - 2
upper <- med + 2

# example 1: no NA values
plot(x, med, type="l", ylim=range(c(lower, upper), na.rm=TRUE))
PolygonNA(x, lower, upper)
lines(x, med)

# example 2: with some NA values 
lower1 <- lower
upper1 <- upper
lower1[c(1, 6, 10)] <- NA
upper1[c(1:2, 6)] <- NA
plot(x, med, type="l", ylim=range(c(lower, upper), na.rm=TRUE))
PolygonNA(x, lower1, upper1)
lines(x, med)

greenbrown documentation built on Dec. 18, 2020, 3:02 p.m.