Search code examples
rpngvenn-diagram

Strange png picture when trying to output a Venn Diagram to png file using venn() from gplots


I want to get my Venn Diagram as a png-file. Here is how it looks when not outputting to file:

library(gplots)
> x <- c("X","B")
> v <- c("X","A")
venn(list(x,v))

Then I get this: http://postimage.org/image/d3nbyrp5f/277b50b3/ , which looks ok.

But doing this:

library(gplots)
> x <- c("X","B")
> v <- c("X","A")
> png(filename="test10.png")
> venn(list(x,v))
> dev.off()

gives this: http://postimage.org/image/tpdywxxrp/a148b2db/ , as you can see the png file does not show a correct Venn Diagram, the circles are overlapping so that a circle is on top the other one...

Any way to overcome this strange behaviour?

EDIT:

It is solved by loading cairoDevice:

library(cairoDevice)

and then use:

Cairo_png(filename="test.png")

to output a Venn Diagram correctly with venn().


Solution

  • This is probably a problem with transparency, you can either use a different tool for venn diagrams, or use a graphics device that supports transparency, I believe that the Cairo devices allow you to create png files and honor the transparency.