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 user-defined colors (left), and monochrome transparent colors (right).

venndir(setlist,
   set_colors=c("firebrick", "orange", "royalblue"))
# blue transparent colors
venndir(setlist,
   poly_alpha=0.4,
   set_colors=c("royalblue", "royalblue", "royalblue"))
Venn diagram showing custom set colors: red, orange, blue.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 also adjusted by poly_alpha to control the alpha transparency. Values range from 0 (fully transparent) to 1 (fully opaque). The default poly_alpha=0.6 is mostly opaque.

Figure 3.7 shows the effect of using low transparency, which allows some background colors to become dark. Notice some text labels become white to maintain 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.7: Venn diagram using opaque colors, which also causes some text labels to become white for visual contrast.

Note:

Some R graphics devices do not support alpha transparency, which can be reviewed with dev.capabilities(). It should be run when the specific graphics device is open, for example after using cairo_pdf() to open a PDF file for output.

Colors can also be customized in any section of the figure, using techniques described in Modify Venn Overlaps.

3.2.1 Consistent Set Colors

When the argument setlist is passed to venndir(), and no custom colors are defined with argument set_colors, categorical colors are assigned to each set.

In a situation where setlist contains five sets, it is recommended to provide all five sets even for a figure that uses only a few sets. The following steps make sure colors are used consistently for each set name.

  1. Supply venndir() with the complete setlist.
  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.8 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.8: Five sets are depicted as circles, each with a specific categorical color.

Figure 3.9 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.9: 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 shows the desired outcome, several Venn diagrams using colors consistent for each set.

Four Venn diagrams using consistent colors for each set.

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

Figure 3.11 shows the problem to avoid, several Venn diagram with colors not consistent for each set.

Four Venn diagrams using the default colors, illustrating the problem to avoid: Colors are not consistent for each set.

Figure 3.11: Four Venn diagrams using the default colors, illustrating the problem to avoid: Colors are not consistent for each set.

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 require black-and-white output.

Figure 3.12 demonstrates Venndir output with no color.

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

Figure 3.12: Venndir figure with no color.

Tip:

Using poly_alpha=0 also makes signed labels not colored.
To maintain signed colors, use poly_alpha=0.01.
For more control over signed label colors, see Custom Sign Label Colors.

References

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