dusadrian / venn

Draw Venn Diagrams
30 stars 7 forks source link

How to draw a rounded rectangular border for the outside box? #16

Closed miraquddus closed 2 years ago

dusadrian commented 2 years ago

You need an external package called grid, for instance:

library(venn)
library(grid)

venn(5, bpx = FALSE)
grid.roundrect(width = 0.98, height = 0.98)
miraquddus commented 2 years ago

Hi Adrian,

Thanks for your prompt guidance. When I applied the grid command, it draws a rounded rectangle on a separate frame. I am not sure how to incorporate in my existing code.

library('venn')
library('ggplot2')
library('grid')
grid.roundrect(width = 0.98, height = 0.98)
intersections <- c('~A~B~C', '~A~BC', '~AB~C', '~ABC', 'A~B~C', 'A~BC', 'AB~C', 'ABC')
venn(intersections, zcolor = c("black","white","white","white", "white","grey100","white","blue"), sncs = .85, ilabels = TRUE, box = FALSE)
dusadrian commented 2 years ago

The grid.roundrect() command should be typed last. First draw the Venn diagram, and only after draw the rounded corners rectangle:

intersections <- c('~A~B~C', '~A~BC', '~AB~C', '~ABC', 'A~B~C', 'A~BC', 'AB~C', 'ABC')
venn(intersections, zcolor = c("black","white","white","white", "white","grey100","white","blue"), sncs = .85, ilabels = TRUE, box = FALSE)
grid.roundrect(width = 0.98, height = 0.98)
miraquddus commented 2 years ago

The rectangle is sitting in front of the venn diagram. In order to make it meaningful, two options: a) make the grid diagram transparent b) push the grid window to the back of the

library('venn')
library('grid')
venn(3, bpx = FALSE, box = FALSE)
grid.roundrect(width = 0.6, height = 0.6)

image_2022-09-06_180442868

dusadrian commented 2 years ago

@miraquddus, this is not happening on my computer, neither on MacOS nor in Windows. And, nevertheless, I have no control over the functions in package grid, you need to read their manual. I see that you have repeatedly used the argument bpx = FALSE, which is not part of the function venn() formal arguments (and, AFAIK, nor is it a formal option for the base par). Is there a special reason you are using that particular thing?

windows macos

miraquddus commented 2 years ago

Thanks for your prompt reply and help to solve the issue. It works now. I really appreciate it.