Abbreviations legend in venneurler

I would like to have a proper legend abbreviations that don't merge with the diagram.

This is my code:

#install.packages('venneuler')
library(rJava)
library(venneuler)
vd <- venneuler(c(A=0.3, B=0.3, C=1.1, "A&B"=0.1, "A&C"=0.2, "B&C"=0.1 ,"A&B&C"=0.1))
plot(vd)

legend("bottomright", legend=c("A=something A\nB=something different in B\nC=something cool in C\n"), title="Labelling")

and this is what I get:

Wrong label:

enter image description here

Can you help me to put long abbreviations out of the Venn diagram.

Upvotes: 2

Views: 118

Answers (1)

user4704857
user4704857

Reputation: 469

Try the below code:

add_legend <- function(...) {
  opar <- par(fig=c(0, 1, 0, 1), oma=c(0, 0, 0, 0), 
    mar=c(0, 0, 0, 0), new=TRUE)
  on.exit(par(opar))
  plot(0, 0, type='n', bty='n', xaxt='n', yaxt='n')
  legend(...)
}

library(rJava)
library(venneuler)
vd <- venneuler(c(A=0.3, B=0.3, C=1.1, "A&B"=0.1, "A&C"=0.2, "B&C"=0.1 ,"A&B&C"=0.1))

par(mar = c(7, 8, 1.4, 0.2))

plot(vd)

add_legend("topleft", legend=c("A=something A\nB=something different in B\nC=something cool in C\n"), title="Labelling")

I have written it based on this post: Plot a legend outside of the plotting area in base graphics?

Upvotes: 1

Related Questions