4.2 Modify Venn Overlaps

Each overlap region in the Venndir object can be customized to some extent. The Venndir object itself can be edited, but this process is tedious and not intended to be user-friendly. Instead modify_venndir_overlap() provides the most common modifications.

For a simple way to highlight a Venndir overlap, see Highlight Venn Overlaps. This alternative offers a simple variation of modify_venndir_overlap().

As described in Venndir Rendering Steps, Sets are drawn as open circles, then each Overlap is drawn as a color-filled region. Labels are then rendered last. Each overlap may have options defined related to the region and the label. For example fill is applied to the polygon background color, however label.fill is applied to the corresponding label. The full set of recognized parameters will be described later.

Overlap regions have specific names using the set or sets involved. * 'set_A' refers to the region unique to 'set_A' with no other overlapping sets. * 'set_A&set_B' refers to the region where the two sets 'set_A' and 'set_B' overlap, with no other overlapping sets.

The overlap name is provided with argument overlap_set. See the example 4.3

# default Venndir
v <- venndir(make_venn_test(do_signed=TRUE),
   do_plot=FALSE)
plot(v,
   main="Default Venndir")

# modified Venndir
v_mod <- modify_venndir_overlap(v,
   overlap_set="set_A&set_B",
   params=list(
      fill="orange",
      alpha=0.8,
      fontsize=c(22, 16, 16),
      innerborder="royalblue",
      innerborder.lwd=5)
   )
plot(v_mod,
   main="Modified 'set_A&set_B'")
Venndir example showing a default Venn diagram, and a modified diagram (right) affecting the overlap region for 'set_A&set_B'. Changes were made to the fill color, innerborder, innerborder.lwd, and fontsize.Venndir example showing a default Venn diagram, and a modified diagram (right) affecting the overlap region for 'set_A&set_B'. Changes were made to the fill color, innerborder, innerborder.lwd, and fontsize.

Figure 4.3: Venndir example showing a default Venn diagram, and a modified diagram (right) affecting the overlap region for 'set_A&set_B'. Changes were made to the fill color, innerborder, innerborder.lwd, and fontsize.

This customization is fairly common, and straightforward:

  • fill color was changed to 'orange'.
  • alpha was defined 0.8, to be applied to fill.
  • innerborder color was changed to 'royalblue'.
  • innerborder.lwd line width was set to 5.
  • Label fontsize values were increased.

Note that fontsize is applied to each individual label in the order it is drawn.

4.2.1 Overlap Attributes

The recognized Venndir overlap attributes are shown in Table 4.1.

Table 4.1: Table 4.2: List of recognized region attributes, used to customize the Venndir figure.
Attribute Description
Region Attributes
fill R color used to fill the overlap region, after also applying alpha. The default is derived from the set_colors for the sets involved.
alpha Numeric alpha transparency applied to the fill color, where alpha=0 is fully transparent, and alpha=1 is opaque.
border R color for the on-edge border. The on-edge border is not recommended for most figures. Use border=NA to draw no border, which is default.
border.lwd The numeric line with for the border when defined.
innerborder R color for the inner-boundary border, recommended in most customizations. When innerborder=NA, or innerborder.lwd=0 the innerborder is not drawn.
innerborder.lwd The numeric line with for the innerborder. When innerborder=NA, or innerborder.lwd=0 the innerborder is not drawn.
outerborder R color for the outer-boundary border, not recommended in most customizations. When outerborder=NA, or outerborder.lwd=0 the outerborder is not drawn.
outerborder.lwd The numeric line with for the outerborder. When outerborder=NA, or outerborder.lwd=0 the outerborder is not drawn.
Label Attributes
fontsize Numeric font size in points for each overlap label as defined in the Venndir object.
label.color Text color for each overlap label as defined in the Venndir object.
label.fill Background label fill color with optional alpha transparency. When label.fill=NA, no fill is applied. The label.fill also affects the label.color, using fill and label.fill together as relevant with make_color_contrast() to ensure contrasting text.
label.border Optional border color around the label group. Use NA for no border.
label.count Position or visibility for each count label as defined the Venndir object. Values are 'outside', 'inside', or 'none'.
label.overlap Position and visibility for the set overlap label. Currently only Set labels can be visible. Values are 'outside', 'inside', or 'none'.