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

View source: R/curve-set.r

plot.curve_setR Documentation

Plot method for the class 'curve_set'

Description

Plot method for the class 'curve_set'

Usage

## S3 method for class 'curve_set'
plot(x, idx, col_idx, idx_name = "", col = "grey70", ...)

Arguments

x

An curve_set object.

idx

Indices of functions to highlight with color col_idx. Default to the observed function, if there is just one. The legend of curves' colours is shown if indices are given or x contains one observed function. See examples to remove the legend if desired.

col_idx

A color for the curves to highlight, or a vector of the same length as idx containing the colors for the highlighted functions. Default exists.

idx_name

A variable name to be printed with the highlighted functions' idx. Default to empty.

col

The basic color for the curves (which are not highlighted).

...

Ignored.

See Also

create_curve_set

Examples

cset <- curve_set(r = 1:10, obs = matrix(runif(10*5), ncol=5))
plot(cset)
# Highlight some functions
plot(cset, idx=c(1,3))
plot(cset, idx=c(1,3), col_idx=c("black", "red"))
# Change legend
plot(cset, idx=c(1,3), col_idx=c("black", "red"), idx_name="Special functions")
plot(cset, idx=c(1,3)) + ggplot2::theme(legend.position="bottom")
# Add labels
plot(cset, idx=c(1,3)) + ggplot2::labs(x="x", y="Value")
# and title
plot(cset) + ggplot2::labs(title="Example curves", x="x", y="Value")
# A curve_set with one observed function (other simulated)
if(requireNamespace("mvtnorm", quietly=TRUE)) {
  cset <- curve_set(obs = c(-1.6, 1.6),
    sim = t(mvtnorm::rmvnorm(200, c(0,0), matrix(c(1,0.5,0.5,1), 2, 2))))
  plot(cset)
  # Remove legend
  plot(cset) + ggplot2::theme(legend.position="none")
}

GET documentation built on Sept. 11, 2024, 5:46 p.m.