dusadrian / venn

Draw Venn Diagrams
29 stars 6 forks source link

add a title for whole figure #14

Closed lwlive closed 2 years ago

lwlive commented 2 years ago

Hi, dusadrian. I am wondering if it is possible to add a title for the venn figure? Can you offer some help! Thanks!

mmahmoudian commented 2 years ago

@lwlive you can use title()

set.seed(12345)

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

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

title(main = "some title here",
      line = -2)

which will result in:

image

if you want to have the title closer to the venn, you should decrease the value of line in the title().

lwlive commented 2 years ago

Hi, dusadrian. I have made it according to your suggestion. Thanks for your kind help!

dusadrian commented 2 years ago

Thanks to @mmahmoudian , actually :)

mmahmoudian commented 2 years ago

@dusadrian it's my pleasure 😊

mmahmoudian commented 2 years ago

@dusadrian Coming back to this, I think there are some merit into letting user to set the title through main argument. So far I have had my wrapper around venn for this and some custom stuff like turning off box and increase the ilcs, but considering the general scheme of packages in R (including base), perhaps for the sake of consistency and usability, it might be a good idea implement this. The default value can be main = "" to be backward compatible.

dusadrian commented 2 years ago

Hello @mmahmoudian, yes I think this would be easy to implement and sensible to have. Will do that in one of the next versions.

dusadrian commented 2 years ago

The latest commit solves this. Not via a formal argument "main" since that requires another argument "line" as per your solution in title() But you can actually provide the arguments "main" and "line" to function venn() via the three dots ... argument, just like you would provide the "main" argument to the base function plot(). Seems to work...