autoplot.radf_obj: Plotting 'radf' models

Description Usage Arguments Value Examples

View source: R/autoplot-radf.R

Description

autoplot.radf_obj takes radf_obj and radf_cv and returns a faceted ggplot object. shade is used as an input to shape_opt. shade modifies the geom_rect layer that demarcates the exuberance periods.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## S3 method for class 'radf_obj'
autoplot(
  object,
  cv = NULL,
  option = c("gsadf", "sadf"),
  min_duration = 0L,
  select_series = NULL,
  include_negative = FALSE,
  shade_opt = shade(),
  include = "DEPRECATED",
  select = "DEPRECATED",
  ...
)

shade(fill = "grey70", opacity = 0.5, ...)

Arguments

object

An object of class obj.

cv

An object of class cv.

option

Whether to apply the "gsadf" or "sadf" methodology (default = "gsadf").

min_duration

The minimum duration of an explosive period for it to be reported (default = 0).

select_series

A vector of column names or numbers specifying the series to be used in plotting. Note that the order of the series does not alter the order used in plotting.

include_negative

If TRUE, plot all variables regardless of rejecting the NULL at the 5 percent significance level.

shade_opt

Shading options, typically set using shade function.

include

Argument name is deprecated and substituted with include_negative.

select

Argument name is deprecated and substituted with select_series.

...

Further arguments passed to ggplot2::facet_wrap and ggplot2::geom_rect for shade.

fill

The shade color that indicates the exuberance periods.

opacity

The opacity of the shade color aka alpha.

Value

A ggplot2::ggplot()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
rsim_data <- radf(sim_data_wdate)

autoplot(rsim_data)

# Modify facet_wrap options through ellipsis
autoplot(rsim_data, scales = "free_y", dir  = "v")

autoplot(rsim_data, shade_opt = shade(fill = "pink", opacity = 0.5))

# We will need ggplot2 from here on out
library(ggplot2)

# Change (overwrite) color, size or linetype
autoplot(rsim_data) +
  scale_color_manual(values = c("black", "black")) +
  scale_size_manual(values = c(0.9, 1)) +
  scale_linetype_manual(values = c("solid", "solid"))

# Change names through labeller (first way)
custom_labels <- c("psy1" = "new_name_for_psy1", "psy2" = "new_name_for_psy2")
autoplot(rsim_data, labeller = labeller(.default = label_value, id = as_labeller(custom_labels)))

# Change names through labeller (second way)
custom_labels2 <- series_names(rsim_data)
names(custom_labels2) <- custom_labels2
custom_labels2[c(3,5)] <- c("Evans", "Blanchard")
autoplot(rsim_data, labeller = labeller(id = custom_labels2))

# Or change names before plotting
series_names(rsim_data) <- LETTERS[1:5]
autoplot(rsim_data)

# Change Theme options
autoplot(rsim_data) +
  theme(legend.position = "right")
 

kvasilopoulos/exuber documentation built on Aug. 8, 2020, 7:52 a.m.