Learn R Programming

fanplot (version 3.3)

fan.txt: Text Labels for Specified Percentiles

Description

This function is no longer recommended. Was intended for use with original fan function (which now goes by fan0). Adds text labels beside relevant percentiles.

Usage

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

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.
...
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
fan0(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
fan0(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)

Run the code above in your browser using DataLab