Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set circle size and label size on venn diagram with matplotlib-venn

I have a couple of different Venn diagrams created with matplotlib-venn library, which share at least one set. I would like the circle of that set to be of the same size on both, so they are comparable. I would also like to change the size of the font of the labels, but I don't understand yet how to get that from the matplotlib-venn functions. How could I do it?

an example of the sets could be something like this:

from matplotlib_venn import venn3

s1=set('abracadabra')
s2=set('alakazam')
s3=set('stackoverflow')
s4=set('hocus pocus')
v_test1=venn3([s1,s2,s3],('set1','set2','set3'))
v_test1=venn3([s1,s3,s4],('set1','set3','set4'))
like image 217
Nabla Avatar asked Sep 01 '17 10:09

Nabla


1 Answers

When you call venn3 function it call solve_venn3_circles to calculate centers and radius of circles. It is mean that you can not set radius by yourself because it is affect the final image and it may be incorrect. However you may try to adjust your circles' size by normalize_to argument of venn3 function.

For font size you can use this code:

for t in v_test1.set_labels: t.set_fontsize(22)
for t in v_test1.subset_labels: t.set_fontsize(20)

Or set font size by id:

label = v_test1.get_label_by_id('111')          
label.set_fontsize(22) 

For id information look for manual page.

like image 101
Serenity Avatar answered Oct 17 '22 09:10

Serenity