How to Create a Proportional Venn Diagram in R


A Venn diagram is a diagram that uses overlapping circles to show the relationship between two groups.

A proportional Venn diagram is a specific type of Venn diagram in which the size of the circles represent the sample size of each group.

The easiest way to create a proportional Venn diagram in R is by using the plot function from the eulerr package.

The following example shows how to do so in practice.

Example: How to Create a Proportional Venn Diagram in R

Suppose we have two groups with the following values:

  • A: 100
  • B: 500
  • A & B Overlap: 75

To create a proportional Venn diagram to visualize the relationship between these two groups, we can use the following code:

library(eulerr)

#specify values to use in venn diagram
fit <- euler(c('A' = 100, 'B' = 500, 'A&B' = 75))

#create venn diagram
plot(fit) 

Notice that the sizes of the circles in the Venn diagram are representative of the values that we specified.

If you would like to customize the colors used in the Venn diagram, you can use the fill argument to do so:

library(eulerr)

#specify values to use in venn diagram
fit <- euler(c('A' = 100, 'B' = 500, 'A&B' = 75))

#create venn diagram with custom colors
plot(fit, fill=c('coral2', 'steelblue')) 

proportional Venn diagram in R

The A circle now has a coral2 fill and the B circle now has a steelblue fill, just as we specified using the fill argument in the plot function.

Note: Refer to this page for a complete introduction to the eulerr package in R.

Additional Resources

The following tutorials explain how to create other common visualizations in R:

How to Create a Grouped Boxplot in R Using ggplot2
How to Create a Heatmap in R Using ggplot2
How to Create a Gantt Chart in R Using ggplot2

Leave a Reply

Your email address will not be published. Required fields are marked *