We could hack the grob thrown by invisible output of draw.triple.venn
.
V <- draw.triple.venn(...) ## catch it in an object
Exploring the object's structure using str(v)
reveals that it's basically a list where there are labels defined in some of the list objects.
str(V)
# [...]
# $ :List of 11
# ..$ label : chr "26030" <-- here "label"
# ..$ x : 'unit' num 0.2npc
# .. ..- attr(*, "valid.unit")= int 0
# .. ..- attr(*, "unit")= chr "npc"
# ..$ y : 'unit' num 0.739npc
# .. ..- attr(*, "valid.unit")= int 0
# .. ..- attr(*, "unit")= chr "npc"
# ..$ just : chr "centre"
# [...]
We can extract them using the bracket function `[[`()
, save them in two distinct temporary objects, and formatC
them using the desired argument big.mark=
. After that we replace untouched temporary object tmp2
with modified temporary object tmp1
where numeric values are non-NA
.
tmp1 <- tmp2 <- lapply(V, `[[`, "label")
tmp1[sapply(lapply(V, `[[`, "label"), is.null)] <- NA
tmp1[] <- ifelse(is.na(as.numeric(tmp1)), NA,
formatC(as.numeric(tmp1), format="d", big.mark=","))
tmp2[!is.na(tmp1)] <- tmp1[!is.na(tmp1)]
Finally, we replace the labels modified with big marks in the grob using Map
and tell R that the class
is "gList"
.
V <- `class<-`(Map(`[[<-`, V, "label", tmp2), "gList")
Now, we can plot the grob using grid.draw
.
grid.newpage()
grid.draw(V)
