konstantint / matplotlib-venn

Area-weighted venn-diagrams for Python/matplotlib
MIT License
496 stars 67 forks source link

broken circle placement #10

Closed jdrudolph closed 10 years ago

jdrudolph commented 10 years ago

I really enjoy using you library but for some of my plots I observed some weird behavior:

rough minmal example:

venn3([set([1,5,8]), set([2,3,4,5,6]), set([5,6,8,9])])

works fine producing: circle_good

while removing one element like below leads to a broken plot

venn3([set([1,5,8]).difference(set([1])), set([2,3,4,5,6]), set([5,6,7,8,9])])

circle_broken

I am using Python 2.7.3 and Matplotlib 1.3.1

konstantint commented 10 years ago

Oh yes, the ugly corner-cases. Those are really hard to test and annoying to solve. The code has to be something like "if two circles intersect like that, then the regions are like that, however, if one circle is inside another, then the regions are instead like that, except for the case when .... etc etc", so I've been closing eyes on most of them so far.

But rants aside, as you brought it up, I tried to apply some band-aid here and there, so at least the case you mentioned should work better now. Do an easy_install --upgrade and try again. Not all the numbers are positioned perfectly in the new version, so if you need this particular image, you'll have to do some manual tuning, e.g.:

v = venn3([set([5,8]), set([2,3,4,5,6]), set([5,6,7,8,9])])
lbl = v.get_label_by_id('010')
(x, y) = lbl.get_position()
lbl.set_position((x+0.1, y+0.1))