Learn R Programming

fanplot (version 2.3)

fan.txt: Text Labels for Specified Percentiles

Description

Adds text labels beside relevant percentiles.

Usage

fan.txt(psims, pn.r = NULL, pn.l = NULL, 
pos = NULL, offset = NULL, cex=0.8, hl.lab=NULL,...)

Arguments

psims
pn object created either by pn function.
pn.r
Vector of percentiles to plot text to the right of the corresponding probability distribution fan. Value must be in the calculated percentiles pn object to be passed to psims.
pn.l
Vector of percentiles to plot text to the left of the corresponding probability distribution fan. Value must be in the calculated percentiles pn object to be passed to psims.
pos
Position specifier for the text. Passed directly to pos argument in text.
offset
Offset for pos. Passed directly to offset argument in text.
cex
Text size of labels. Passed directly to text.
hl.lab
String of length 2, with low/lowest/bottom labels first and high/highest/top labels second.
...
Additional arguments passed to text to control label characteristics.

Value

  • See details

Details

Returns text labels in plot figure. Particularly useful if probability distributions over time are not a forecast fan, to allow labels to be added on the left hand side of the plot. Additional arguments control text properties, such as position, size and colour.

See Also

fan

Examples

Run this code
# calculate percentiles across time
th.pn <- pn(sims = th.mcmc)

##
##Add text
##
# empty plot
plot(NULL, type = "n", xlim = c(1, 945),  ylim = range(th.pn), ylab = "Theta")

# add fan
fan(th.pn, txt = NULL)

# add text
fan.txt(th.pn, pn.l = c(1, 10, 50, 90, 99))
fan.txt(th.pn, pn.r = c(1, seq(10, 90, 20), 99)) 

##
##Change text position, size and colour
##
# empty plot
plot(NULL, type = "n", xlim = c(1, 945),  ylim = range(th.pn), ylab = "Theta")

# add fan
fan(th.pn, txt = NULL)

# add text
fan.txt(th.pn, pn.l = c(1, 10, 50, 90, 99), pos = 1, offset = 0)
fan.txt(th.pn, pn.r = c(1, seq(10, 90, 20), 99), col = "royalblue", cex = 2) 

##
##Prediction Intervals
##
th.pn <- pn(sims = th.mcmc, p.int=seq(10,90,10), type="intervals")
head(th.pn)
plot(NULL, type = "n", xlim = c(1, 945), ylim = range(th.pn), ylab = "Theta")
fan(th.pn, ln=c(50,80,90), hl.lab=c("L","U"))
fan.txt(th.pn, pn.l = c(10,30,70), hl.lab=c("L","U"))

Run the code above in your browser using DataLab