plot_sf: Plot percentile bootstrap shift function

View source: R/shift_function_plot.R

plot_sfR Documentation

Plot percentile bootstrap shift function

Description

Plot one or more shift functions generated with shifthd, shiftdhd, shifthd_pbci or shiftdhd_pbci. Assumes the median was estimated and is the middle value. The function returns a list of ggplot objects, which can be customised using the ggplot2 package.

Usage

plot_sf(
  data = df,
  plot_theme = 1,
  symb_col = NULL,
  symb_fill = NULL,
  symb_size = 5,
  symb_shape = 21,
  diffint_col = NULL,
  diffint_size = 0.5,
  q_line_col = NULL,
  q_line_alpha = 0.5,
  q_line_size = 1.5,
  theme2_alpha = NULL
)

Arguments

data

A list of data frames generated by shifthd_pbci or shiftdhd_pbci.

plot_theme

One of 3 themes - default is 1.

symb_col

Contour colour of quantile symbol.

symb_fill

Fill colour(s) of quantile symbol. Defaults are "white" for theme 1, c("darkviolet","darkorange2") for theme 2, c("white", "grey") for theme 3.

symb_size

Size of quantile symbol - default = 5.

symb_shape

Shape of the quantile symbol - default = 21 (disc).

diffint_col

Colour of the lines marking the quantile difference intervals.

diffint_size

Size of the lines marking the quantile difference intervals - default = .5.

q_line_col

Colour of the line joining the quantiles.

q_line_alpha

Alpha of the line joining the quantiles - default = .5.

q_line_size

Size of the line joining the quantiles - default = 1.5.

theme2_alpha

Alpha transparency for theme 2 - default c(0.4, 1)

Details

Several themes are available:

  • Theme 1 uses a minimalist design with the same colour for all quantiles.

  • Theme 2 colour codes the sign of the differences.

  • Theme 3 uses a greyscale gradient to code the quantiles.

Examples

plot_sf(out) # default plot
plot_sf(out, plot_theme = 2) # specify theme
plist <- plot_sf(out) # output list of ggplot objects

# The plots can then be combined using \href{https://cran.r-project.org/web/packages/gridExtra/index.html}{gridExtra} or \href{https://cran.r-project.org/web/packages/cowplot/index.html}{cowplot} - for instance:
library(gridExtra)
do.call("grid.arrange", c(plist, ncol=2))
# To extract one object and for instance change a label:
p <- plist[[1]]
p + labs(y = "Difference")


GRousselet/rogme documentation built on Nov. 12, 2022, 4:38 a.m.