I use VennDiagram to make a venn diagram with the following example code:
library(VennDiagram)
venn.diagram(list(shams_90d = 1:3, shams_90d_4h = 2:4, sham3__shams_90d = 3:5,
sham3_90d__shams = 5:7, sham3_90d__shams_4h = 6:9),
fill = c("red", "green", "blue", "yellow", "purple"),
alpha = c(0.5, 0.5,0.5, 0.5, 0.5), cex = 1,cat.fontface = 2,
lty =1, filename = "trial2.emf");
Which gives this figure:
The names on the left and right of the figure are cut off, and a little bit of the name at the bottom as well. I tried changing width, but that makes the venn diagram itself get wider, and the names still get cut off.
How can I make the VennDiagram so that it includes the full names, either by adding more whitespace on the left and right of the diagram, or by pushing the names more towards the venn diagram?
You can justify the label text with cat.just
. The package reference manual gives info. on how to pass the parameters.
For your example i used trial and error for the justification values.
# Plot
v <- venn.diagram(list(shams_90d = 1:3, shams_90d_4h = 2:4, sham3__shams_90d = 3:5,
sham3_90d__shams = 5:7, sham3_90d__shams_4h = 6:9),
fill = c("red", "green", "blue", "yellow", "purple"),
alpha = c(0.5, 0.5,0.5, 0.5, 0.5), cex = 1,cat.fontface = 2,
lty =1, filename=NULL, cat.cex=0.8,
cat.just=list(c(0.6,1) , c(0,0) , c(0,0) , c(1,1) , c(1,0)))
grid.newpage()
grid.draw(v)
Another option (if a bit of a quick hack) would be to remove the cat.just
argument and set a smaller grid::viewport
. You may need to tweak the width of your graphics window / output device (ie pdf(..., width=...)
):
# Plot
v <- venn.diagram(list(shams_90d = 1:3, shams_90d_4h = 2:4, sham3__shams_90d = 3:5,
sham3_90d__shams = 5:7, sham3_90d__shams_4h = 6:9),
fill = c("red", "green", "blue", "yellow", "purple"),
alpha = c(0.5, 0.5,0.5, 0.5, 0.5), cex = 1,cat.fontface = 2,
lty =1, filename=NULL, cat.cex=0.8)
grid.newpage()
pushViewport(viewport(width=unit(0.8, "npc"), height = unit(0.8, "npc")))
grid.draw(v)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With