dusadrian / venn

Draw Venn Diagrams
30 stars 7 forks source link

Specify the order of sets? #20

Closed lucygarner closed 1 year ago

lucygarner commented 1 year ago

Hi,

Is it possible to specify the order of the sets in the Venn diagram?

Best wishes, Lucy

dusadrian commented 1 year ago

Hi @lucygarner,

If you mean the order in which the sets are printed on the diagram, there is the "snames" argument in the main function venn().

Otherwise, more details are needed about your particular need.

Best, Adrian

mmahmoudian commented 1 year ago

If I understand the question correctly, it is already possible because the order is based on the input data:

set.seed(12345)

a <- list(first = sample(x = letters, size = 20, replace = FALSE),
          second = sample(x = letters, size = 20, replace = FALSE),
          third = sample(x = letters, size = 20, replace = FALSE))

venn(a,
     zcolor = c(1,2,3),
     box = FALSE,
     ilcs = 2)

image

now if you define your order:

my_order <- c(2,3,1)

venn(a[my_order],  #<-------------------------------------- specified order here
     zcolor = c(1,2,3)[my_order], #<----------------------- and here
     box = FALSE,
     ilcs = 2)

image

using the sname as @dusadrian suggested would change the order, but would keep the colors and other features in original (i.e provided) order:

venn(a,
     zcolor = c(1,2,3),
     box = FALSE,
     snames = c("second", "third", "first"), #<------------ specified order here
     ilcs = 2)

image

lucygarner commented 1 year ago

Ok great, thank you both. I will give this a go.