plot.global_envelope: Plot method for the class 'global_envelope'

View source: R/envelopes.r

plot.global_envelopeR Documentation

Plot method for the class 'global_envelope'

Description

Plot method for the class 'global_envelope'

Usage

## S3 method for class 'global_envelope'
plot(
  x,
  dotplot = length(x$r) < 10,
  sign.col = "red",
  labels = NULL,
  digits = 3,
  ...
)

Arguments

x

An 'global_envelope' object

dotplot

Logical. If TRUE, then instead of envelopes a dot plot is done. Suitable for low dimensional test vectors. Default: TRUE if the dimension is less than 10, FALSE otherwise.

sign.col

The color for the observed curve when outside the global envelope (significant regions). Default to "red". Setting the color to NULL corresponds to no coloring. If the object contains several envelopes, the coloring is done for the widest one.

labels

A character vector of suitable length. If dotplot = TRUE, then labels for the tests at x-axis.

digits

The number of digits used for printing the p-value or p-interval in the default main.

...

Ignored.

See Also

central_region, global_envelope_test

Examples

if(require("spatstat.explore", quietly=TRUE)) {
  X <- unmark(spruces)
  nsim <- 1999 # Number of simulations
  
  env <- envelope(X, fun="Kest", nsim=nsim,
                  savefuns=TRUE, # save the functions
                  correction="translate", # edge correction for K
                  simulate=expression(runifpoint(ex=X))) # Simulate CSR
  res <- global_envelope_test(env, type="erl")

  # Default plot
  plot(res)
  # Plots can be edited, e.g.
  # Remove legend
  plot(res) + ggplot2::theme(legend.position="none")
  # Change its position
  plot(res) + ggplot2::theme(legend.position="right")
  # Change the outside color
  plot(res, sign.col="#5DC863FF")
  plot(res, sign.col=NULL)
  # Change default title and x- and y-labels
  plot(res) + ggplot2::labs(title="95% global envelope", x="x", y="f(x)")

  # Prior to the plot, you can set your preferred ggplot theme by theme_set
  old <- ggplot2::theme_set(ggplot2::theme_bw())
  plot(res)

  # Do other edits, e.g. turn off expansion with the default limits
  plot(res) + ggplot2::coord_cartesian(expand=FALSE)

  # Go back to the old theme
  ggplot2::theme_set(old)

  # If you are working with the R package spatstat and its envelope-function,
  # you can obtain global envelope plots in the style of spatstat using plot.fv:
  plot.fv(res)
}

GET documentation built on Nov. 16, 2022, 5:09 p.m.