nudge_venndir_label: Nudge venndir labels

nudge_venndir_labelR Documentation

Nudge venndir labels

Description

Nudge venndir labels

Usage

nudge_venndir_label(
  venndir_output,
  set = NULL,
  x_offset = 0,
  y_offset = 0,
  offset_list = NULL,
  align_y = c("none", "top", "middle", "bottom"),
  align_x = c("none", "left", "center", "right"),
  unit_type = c("relative", "absolute"),
  label_location = "outside",
  verbose = FALSE,
  ...
)

Arguments

venndir_output

output from venndir() as Venndir object.

set

character name of the sets or overlaps to adjust.

x_offset, y_offset

numeric coordinates to adjust, recycled to the number of entries provided in set.

offset_list

list (default NULL) used as a shorthand alternative to set,x_offset,y_offset. The format is a list with x,y offset values, with list elements named by set. For example: offset_list = list(setA=c(0, 0.1), set_B=c(-0.1, 0))

align_y, align_x

character string for optional alignment of labels, where all labels in set are aligned.

  • This option is recommended only with label_location="outside", in order to align labels relative to each other.

  • It is recommeded for example, to make sure two top labels are placed at the same height relative to each other.

  • All labels in set are adjusted as a group, after applying x_offset,y_offset.

  • The coordinates of all labels in set are used, then the target coordinate is defined by the logic:

  • ⁠"top","middle","bottom"⁠ - uses the highest, middle, or lowest coordinate among the labels in set.

  • ⁠"left","center","right"⁠ - uses the left-most, center, or right-most coordinate among the labels in set.

unit_type

character string (default "relative") defining how to interpret the x_offset,y_offset values.

  • "relative" - interprets the adjustment relative to the plot bounding box, specifically the largest axis span. This option is useful when the plot span is not known.

  • "absolute" - interprets the adjustment with absolute units, which is useful when the plot span is known.

label_location

character string (default "outside") indicating which label coordinate to adjust:

  • "outside" - will only adjust the outer label, leaving the inner label position unaffected.

  • "inside" - will only adjust the inner label, leaving the outer label position unaffected.

  • "all" - will adjust both the inner and outer label positions together.

verbose

logical indicating whether to print verbose output.

...

additional arguments are ignored.

Details

Venndir labels are defined for each overlap polygon, with "inner" and "outer" label coordinates for each polygon. The show_labels argument to venndir() defines which labels are placed inside and outside the Venn diagram polygons. This function is useful to adjust the position of one or more labels.

This function does not determine whether labels are displayed inside or outside the Venn polygons.

Value

Venndir object after adjusting label coordinates

See Also

Other venndir utility: curate_venn_labels(), expand_range(), make_color_contrast(), make_venn_combn_df(), make_venn_test(), match_list(), modify_venndir_overlap(), plot,Venndir,ANY-method, print_color_df(), shrink_df(), three_point_angle(), venndir_legender(), venndir_to_df()

Examples

setlist1 <- make_venn_test(100, 3, do_signed=TRUE)

vo1 <- venndir(setlist1,
   overlap_type="each",
   return_items=TRUE,
   label_style="lite_box",
   main="Default venndir")
render_venndir(vo1)

head(vo1@label_df[, c("x", "x_offset", "y", "y_offset")], 3)
subset(vo1@label_df, overlap_set %in% "set_A")[, c("x", "x_offset", "y", "y_offset")]

vo2 <- nudge_venndir_label(vo1,
   set=c("set_A", "set_B"),
   x_offset=c(-0.1, 0.1),
   y_offset=c(0))
render_venndir(vo2)

# alternative with offset_list
vo2b <- nudge_venndir_label(vo1,
   offset_list=list(
      set_A=c(0.1, 0),
      set_B=c(0.1, 0),
      set_C=c(0.4, 0.4)))
render_venndir(vo2b)

# now align two labels at the top
vo2c <- nudge_venndir_label(vo2b,
   set=c("set_A", "set_B"),
   align_y="top")
render_venndir(vo2c)


jmw86069/venndir documentation built on Dec. 14, 2024, 2:36 p.m.