Learn R Programming

Renext (version 2.1-0)

RLlegend: Legend management for return level plots

Description

Legend management for return level plots produced with the plot and lines method of the "Renouv" class.

Usage

RLlegend.ini(x = "topleft", bty = "n", envir, ...)
    RLlegend.show(envir)

Arguments

x
A possible value for the x argument of legend. This will usually be a character giving the position e.g, "topleft" or "bottomleft". See the
bty
As in legend. The default value "n" differs from the default value of legend.
envir
An environment in which a variable .RLlegend will be stored.
...
Other arguments to be kept in the list and passed later to legend. These arguments should chosen among those of legend modifying the global legend appearance (e.g., bg)

Value

  • RLlegend.ini returns a copy of the variable which is set. RLlegend.show returns nothing.

Details

This function is to be used in conjunction with plot.Renouv and lines.Renouv methods. It allows the construction of a legend in a semi-automatic fashion, using the value of the par argument of the plot and lines methods to specify the legend construction. Each call to the plot.Renouv or lines.Renouv changes the content of a list variable named .RLlegend in the environment defined by the envir formal. This list is re-created when RLlegend.ini is called, and is used later to draw a legend on the active device when RLlegend.draw is called. Between these two calls, the plot and lines methods should be used with their arg legend set to FALSE.

The list variable used to store the needed information can be assigned into the global environment at the user responsibility by a suitable choice of envir.

See Also

plot.Renouv and lines.Renouv for and the RLpar function to change the graphical parameters of the plot and the legend by using the par argument.

Examples

Run this code
## use Garonne data
xG <- Garonne$OTdata$Flow
## use spetial "exponential" distribution 
fit1 <- Renouv(x = xG, threshold = 2500, distname.y = "exponential",
               effDuration = 65, plot = FALSE)

## use 'exp' in black box fashion, hence with delta method
fit2 <- Renouv(x = xG, , threshold = 2500, distname.y = "exp",
               effDuration = 65, start.par.y = c(rate = 1), plot = FALSE)

legEnv <- new.env()
RLlegend.ini(envir = legEnv) ## initialise legend

## sample points only
plot(fit1, main = "Two types to confidence lims",
     show = list(OT = TRUE, quant = FALSE, conf = FALSE),
     label = "",
     legend = FALSE)
## quant and confidence lims
lines(fit1,
     show = list(OT = FALSE, quant = TRUE, conf = TRUE),
     label = "exact",
     legend = TRUE,
     legendEnvir = legEnv)
## quant (overplot) and confidence lims
lines(fit2,
      show = list(OT = FALSE, quant = TRUE, conf = TRUE),
      par = RLpar(quant.lty = 2, quant.col = "SpringGreen2",
        conf.conf1.col = "orangered", conf.conf1.lwd = 3,
        conf.conf2.col = "orangered", conf.conf2.lwd = 3),
      label = "delta",
      legend = TRUE,
      legendEnvir = legEnv)

RLlegend.show(envir = legEnv) ## now draw legend

Run the code above in your browser using DataLab