4.9 Nudge specific labels

Venndir automatically places labels which aims to cover the most common 85% scenarios. For all other cases, labels can be re-positioned using nudge_venndir_label().

  • For each overlap, the label can be displayed 'inside' or 'outside'.
  • The position defined for 'inside' or 'outside' can be adjusted with nudge_venndir_label().

As such, a label position is identified by two criteria:

  1. Overlap: each set name, separated by ampersand '&', for example 'set_A&set_B'
  2. Location: 'inside' or 'outside' the Venn diagram.

The components of each label, and placement 'inside' or 'outside', are stored in the Venndir object as described in Venndir Labels. Individual changes can be made by following Customize Any Label.

Instead, nudge_venndir_label() adjusts the coordinate position used when placing each label 'inside' or 'outside'.

setlist <- make_venn_test(100, 3, do_signed=TRUE)
vo <- venndir(setlist,
   overlap_type="each",
   label_style="lite box",
   main="Default venndir")
Venndir example with default label placement.

Figure 4.13: Venndir example with default label placement.

The example in Figure 4.13 is the default Venndir, however in this case the label 7 between 'set_A' and 'set_C' will be nudged slightly to the left. The result is shown in Figure 4.14 after nudging the label 2% to the left.

vo2 <- nudge_venndir_label(vo,
   set="set_A&set_C",
   label_location="inside",
   x_offset=-0.02)
plot(vo2)
Venndir with the label 'set_A&set_C' moved slightly to the left.

Figure 4.14: Venndir with the label 'set_A&set_C' moved slightly to the left.

The changes were defined by these arguments:

  • The overlap was defined with set="set_A&set_C"
  • The location was defined with label_location="inside"
  • The x position was adjusted with x_offset=-0.02, with default units relative to the total size of the figure.

An alternative approach may be more convenient, using argument offset_list. The argument is a list, named by overlap, containing a two-value numeric vector with the x,y offset values. This style is more convenient when adjusting multiple labels together. Note that label_location is still required.

Figure 4.15 shows the effects after nudging labels 'set_A&set_C' and 'set_C' in one step.

vo3 <- nudge_venndir_label(vo,
   label_location="inside",
   offset_list=list(
      "set_A&set_C"=c(-0.02, 0),
      "set_C"=c(0, 0.05)
   ))
plot(vo3)
Venndir after moving labels 'set_A&set_C' and 'set_C' using offset_list.

Figure 4.15: Venndir after moving labels 'set_A&set_C' and 'set_C' using offset_list.