Skip to contents

Position labels outside JamPolygon

Usage

label_outside_JamPolygon(
  jp,
  which_jp = NULL,
  center = NULL,
  buffer = -0.1,
  distance = 0.1,
  center_method = c("bbox", "label"),
  vector_method = c("label", "farthest"),
  segment_method = c("nearest", "vector"),
  min_degrees = 15,
  relative = TRUE,
  y_snap_percent = 5,
  seed = 123,
  debug = FALSE,
  do_plot = FALSE,
  verbose = FALSE,
  ...
)

Arguments

jp

JamPolygon

which_jp

integer or NULL; when which_jp contains one or more integer values, they refer to rows in jp, and each will be analyzed in sequence. When which_jp=NULL then all the polygons in jp will be analyzed in sequence.

center

numeric vector or matrix with two values indicating the center position. When center=NULL then the center is determined using a method defined by center_method.

buffer

numeric buffer, default -0.1, inside the polygon used to draw a line segment connecting the label to the appropriate polygon.

distance

numeric value, default 0.1, indicating the distance from the perimiter of jp to place labels. This value is the buffer for buffer_JamPolygon().

center_method

character string indicating the method to determine the center:

  • "label" uses the mean x,y coordinate of all the polygon label positions;

  • "bbox" uses the mean x,y coordinate of the bounding box that encompasses the polygons.

The effect is to extend outer labels radially around this center point. Using the mean label position with center_method="label" is helpful because it ensures labels are extended in all directions even when most labels are in one upper or lower section of the sp polygons.

min_degrees

numeric, default 15, minimum degrees spacing to impose between label positions, oriented around the center. When there are more labels than can be divided, the threshold is automatically lowered proportionally.

relative

logical whether distance and buffer are relative to plot dimensions, default TRUE.

y_snap_percent

numeric percent of the plot dimensions used to decide whether to "snap" two labels to the same y-axis value. Default 5 means any labels within 5 percent of the plot dimensions of one or more other labels will use the mean y-axis value, thereby helping align labels by height where appropriate.

seed

numeric used to set the random seed for reproducibility, via set.seed(). Default is 123.

debug

logical whether to print detailed debug information.

do_plot

logical whether to create a plot with the input jp and corresponding labels and line segments assigned to which_jp. Default is FALSE.

verbose

logical whether to print verbose output.

...

additional arguments are ignored.

Examples

v <- venndir(make_venn_test(n_sets=3), do_plot=FALSE)
jps <- v@jps

# plot visual summary
label_outside_JamPolygon(jps, do_plot=TRUE)