[R] colored venn diagram

Peter Ehlers ehlers at ucalgary.ca
Thu May 20 05:45:24 CEST 2010


Tao,

You might also have a look at the venneuler package.

  -Peter Ehlers

On 2010-05-19 21:37, David Winsemius wrote:
>
> On May 19, 2010, at 7:15 PM, Shi, Tao wrote:
>
>> Hi list,
>>
>> This is probably too much to ask, but I'm wondering if there is a
>> ready-to-use function somewhere that allows me to color one area of a
>> venn diagram (e.g. the intersection of two sets)?
>>
>
> There is an intersectDiagrapm in plotrix that accepts color arguments,
> although it is not really a Venn diagram.
>
> The venn function in gplots does not accept color. It is a wrapper to
> getVennCounts and drawVennDiagram, and if you hack the second function
> you can get colors. For the example in the help page for Venn, you need
> to find the section that handles the correct number of sets and add a
> color argument to the polygon call. If you want intersections you will
> need transparency. I do not know how to address specific subsets:
>
> require(gplots)
> require(seqinr) # for col2alpha for transparency
>
> getAnywhere(drawVennDiagram) # add an assignment operator and trim out
> this stuff----
> A single object matching ‘drawVennDiagram’ was found
> It was found in the following places
> namespace:gplots
> with value
> ----------end trimming--------------
> function (data, small = 0.7, showSetLogicLabel = FALSE, simplify = FALSE)
> {
> numCircles <- NA
> .
> .
> # make mod to n==4 section
> + polygon(relocate_elp(elps, 45, 130, 170), col=col2alpha("red", 0.5) )
> + polygon(relocate_elp(elps, 45, 200, 200), col=col2alpha("blue", 0.5) )
> + polygon(relocate_elp(elps, 135, 200, 200))
> + polygon(relocate_elp(elps, 135, 270, 170))
> .
> .
> ... And then pass the result from venn to drawVennDiagram:
>
> gv <- venn(input)
> drawVennDiagram(data = gv, small = 0.7, showSetLogicLabel = FALSE,
> simplify = FALSE)
>
> Set #1 in pink set2 in blue and the intersection is purple.
>



More information about the R-help mailing list