3.2 Venn Set Colors

The argument set_colors is used to define colors for each set. When it is NULL, as by default, it assigns rainbow categorical colors by calling the colorjam (Ward 2025) R package.

Figure 3.6 demonstrates the effect of user-defined colors.

venndir(setlist,
   set_colors=c("firebrick", "orange", "royalblue"))
Venn diagram showing custom set colors: red, orange, blue.

Figure 3.6: Venn diagram showing custom set colors: red, orange, blue.

The background fill color is adjusted by poly_alpha which controls the alpha transparency of the color. Values range from 0 (fully transparent) to 1 (fully opaque). The default poly_alpha=0.6 is mostly opaque.

Figure 3.7 illustrates the effect of using more transparent colors, which also lightens the background colors.

venndir(setlist,
   poly_alpha=0.4,
   set_colors=c("royalblue", "royalblue", "royalblue"))
Venn diagram using more transparent set colors.

Figure 3.7: Venn diagram using more transparent set colors.

Figure 3.8 shows the effect with low transparency, causing background colors to become dark. Notice some text labels become white to improve the visual contrast.

venndir(setlist,
   set_colors=c("firebrick", "orange", "royalblue"),
   poly_alpha=0.9)
Venn diagram using opaque colors, which also causes some text labels to become white for visual contrast.

Figure 3.8: Venn diagram using opaque colors, which also causes some text labels to become white for visual contrast.

Tip:

Note that some R graphics devices do not support alpha transparency, which you can check with dev.capabilities(). It may need to be run when the specific graphics device is open, for example after using cairo_pdf() to open a PDF file for output.

Colors can be manually changed later, in any section of the figure, which is described later in Modify Venn Overlaps.

3.2.1 Consistent Set Colors

When setlist is provided to venndir(), it assigns one color to each set, unless colors are defined upfront using argument set_colors.

Consider having five sets, the following technique ensures that colors are used consistently for each set name.

  1. Supply venndir() with the setlist with all sets.
  2. Use argument sets to indicate which entries in setlist should be used.
  3. Optionally define set_colors, setlist_labels, and legend_labels for all sets in setlist.

Figure 3.9 represents five sets with specific categorical colors assigned to each set. When making Venn diagrams with two sets, they should use consistent colors.

Five sets are depicted as circles, each with a specific categorical color.

Figure 3.9: Five sets are depicted as circles, each with a specific categorical color.

Figure 3.10 shows the effects in a Venn diagram with sets A and E, using the respective colors.

setlist <- make_venn_test(n_sets=5, n_items=70, set_names=LETTERS[1:5])
v2 <- venndir(setlist,
   sets=c(1, 5))
Venn diagram comparing sets A and E. The colors are taken from the five-color palette, using yellow for A, and blue for E.

Figure 3.10: Venn diagram comparing sets A and E. The colors are taken from the five-color palette, using yellow for A, and blue for E.

Figure 3.11 shows the effect put into action, with several Venn diagrams shown with consistent colors for each set.

Four Venn diagrams using consistent colors for each set.

Figure 3.11: Four Venn diagrams using consistent colors for each set.

Figure 3.12 illustrates the problem this technique tries to avoid, these examples use the same colors in each figure without regard to the sets involved.

Four Venn diagrams using the default colors, gold and red.

Figure 3.12: Four Venn diagrams using the default colors, gold and red.

Other alternatives to avoid mis-using color:

  • Supply argument set_colors to venndir() with specific colors per set.
  • Create Venn with no color, and no background fill.

3.2.2 Venndir Without Color

It is possible to create a Venndir without color. For example, some publications are limited to black-and-white output.

Figure X demonstrates the arguments required to create a Venn diagram without color.

v <- venndir(make_venn_test(),
   poly_alpha=0,
   border="black",
   border.lwd=2,
   legend_color_style=c("blackborder", "nofill"))
Venndir figure with no color.

Figure 3.13: Venndir figure with no color.

References

Ward, James M. 2025. Colorjam: Jam Color Manipulation Functions. https://jmw86069.github.io/colorjam.