4.5 Highlight Venn Overlaps

A convenient alternative to the previous section Modify Venn Overlaps is to apply a highlight with highlight_venndir_overlap(). This step applies a few options together.

The default settings:

  • gold border
  • yellow fill color
  • red
  • fill = 'yellow'
  • innerborder = 'gold'
  • border = 'red'

The example in 4.7 shows the effect of highlighting one overlap region, 'set_B&set_C'. The third panel demonstrates how to move the count labels outside with a background fill color. The line segment color is defined by border with default 'red', however if 'label.border' is defined, that color is slightly darkerned and used for the line segment as well.

# default Venndir
v <- venndir(make_venn_test(do_signed=TRUE), do_plot=FALSE)
plot(v,
   main="Default Venndir")
v_mod <- highlight_venndir_overlap(v,
   border="red",
   "set_B&set_C")
plot(v_mod,
   main="Highlighted set_B&set_C")
v_mod2 <- modify_venndir_overlap(v_mod, "set_B&set_C",
   params=list(label.count="outside",
      label.fill="gold"))
plot(v_mod2,
   main="Highlighted set_B&set_C outside")
Example Venn diagrams showing default (left), highlighted (right), and highlighted-labeled alternatives.Example Venn diagrams showing default (left), highlighted (right), and highlighted-labeled alternatives.Example Venn diagrams showing default (left), highlighted (right), and highlighted-labeled alternatives.

Figure 4.7: Example Venn diagrams showing default (left), highlighted (right), and highlighted-labeled alternatives.

The overlap region is named using each set involved, separated by the ampersand '&', for example the overlap of 'set_B' and 'set_C' is named 'set_B&set_C'. The overlap is provided with argument overlap_set.

Other arguments are intended to provide convenient shortcuts for commonly used attributes, with sensible default values:

  • 'innerborder' - the border shown on the inside edge of the overlap region.
  • 'innerborder.lwd' - the width of the innerborder, with default 2 to make this border much wider than the default.
  • outerborder', 'outerborder.lwd' - the corresponding outerborder displayed on the outside edge of the overlap region. By default the outerborder line width is zero.
  • 'border', 'border.lwd' - the color and width of the border, placed on the edge of the polygon itself. The default uses 'red' with line width 1. The main effect is to apply this color and line width to the line segment when the overlap label is outside.
  • reorder - a logical value indicating whether to re-order the Venndir polygons. The default is TRUE, which causes the highlighted regions to be drawn last. This subtle change ensures that the outerborder remains visible, and is not over-drawn by other polygon regions in the Venndir object.

The argument reorder is a unique enhancement for highlight_venndir_overlap(), and is the only convenient method for re-ordering Venndir polygons.