draw_oneway_contrast: Draw one-way contrast using block arrows

draw_oneway_contrastR Documentation

Draw one-way contrast using block arrows

Description

Draw one-way contrast using block arrows

Usage

draw_oneway_contrast(
  x0,
  x1,
  y0,
  y1,
  color = "peachpuff",
  border = "black",
  plot_type = c("base", "grid"),
  label = NULL,
  label_sep = "\n",
  na.rm = TRUE,
  label_color = "white",
  label_cex = 1,
  label_font = 2,
  oneway_position = 0.5,
  do_plot = TRUE,
  verbose = FALSE,
  debug = FALSE,
  ...
)

Arguments

x0, x1, y0, y1

numeric values with the start and end coordinates, for the x and y axes, respectively.

color, border

character R colors used to define color fill and border, respectively, for each block arrow,

plot_type

character string indicating the type of plot output:

  • "base": base R graphics

  • "grid": grid graphics (not yet implemented)

label

character vector or list with optional label to display atop each block arrow. For base R graphics, the label is drawn using jamba::shadowText() to render an outline around the text.

  • When label is a character vector, it is converted to a list in two ways depending upon the number of block arrows (length(x0)):

    • length == 1: label is converted to list with length == 1.

    • length > 1: label is converted to list using as.list, then expanded to length(x0).

  • When label is passed as a list, or after label is converted to a list:

    • Each block arrow label uses one concatenated string after calling jamba::cPaste(..., sep=label_sep) which joins values by default using newline "\n" between each value.

label_sep

character string used as separator, passed to jamba::cPaste(), so that each block arrow may contain a vector which is concatenated using label_sep between each value. By default label_sep="\n" which prints each value on a new line.

na.rm

logical passed to jamba::cPaste() to define how to display NA labels:

  • na.rm=FALSE: "NA"

  • na.rm=TRUE: "".

label_color

character color used for the label.

label_cex

numeric label font expansion factor, used to adjust the font size of the text label.

label_font

numeric indicating the font face, defined as:

  • 1 = normal font

  • 2 = bold font

  • 3 = italic font

  • 4 = bold, italic font

do_plot

logical indicating whether to draw the block arrow.

verbose

logical indicating whether to print verbose output.

debug

logical indicating whether to print additional debug info.

...

additional arguments are passed to make_block_arrow_polygon(), including arrow_ex the arrow size expansion factor, and head_ex the arrow head expansion factor, which is adjusted relative to the arrow stem width.

Examples

plot(NULL, xlim=c(0, 5), ylim=c(0, 4), asp=1, xlab="", ylab="")
draw_oneway_contrast(1, 4, 1, 1, label="contrast label")
draw_oneway_contrast(1, 4, 2, 2, head_ex=2, label_cex=1, label="contrast label")
draw_oneway_contrast(1, 4, 3, 3, arrow_ex=2, label_cex=2, label="contrast label")
draw_oneway_contrast(3, 0, 4, 1, arrow_ex=2, label_cex=2, label="contrast label")


jmw86069/jamses documentation built on May 31, 2024, 1:36 p.m.