Ahdee
Ahdee

Reputation: 4949

Manually set color for venn diagrams in Vennerable package

Hi I would like to be able to manually assign the colors. For example

library(Vennerable)
data(StemCell)
  w <- Venn(Sets=StemCell[1:2])
  plot(w, type="squares")

produces enter image description here

however what I would like to do is manaully change the color, OCT4=red, overlap=brown and Sox2=green? is this possible with the current package? I tried setting gpar but it did not appear to do anything in particular.

thanks! A

Upvotes: 1

Views: 2549

Answers (1)

4rj4n
4rj4n

Reputation: 356

Part of this is documented in the Vennerable vignette (vignette("Venn")), section 2.3 Graphical parameters, and the VennThemes man page (?VennThemes)

The customization that you would like to have requires you to make use of compute.Venn() additional to Venn(), to compute an appropriate diagram that you can then customize using VennThemes().

The code for your required customization looks like this:

w <- compute.Venn(Venn(Sets=StemCell[1:2]), type = "squares")
gp <- VennThemes(w)
gp[["Face"]][["11"]]$fill <-  "brown"
gp[["Face"]][["01"]]$fill <-  "green"
gp[["Face"]][["10"]]$fill <-  "red"
plot(w, gp = gp)

Customized Venn plot

You can look at the object "gp", that contains all visualization settings, like fill of the Venn that is altered in the code above, but also colour of line, text, etc. Have fun playing around with that.

btw, in the vignette, they make use of grid package

library(grid)
grid.newpage()

to wipe the slate. Otherwise you're plotting Venn on top of Venn diagram.

Upvotes: 4

Related Questions