konstantint / matplotlib-venn

Area-weighted venn-diagrams for Python/matplotlib
MIT License
519 stars 68 forks source link

Have problem with representing the intersection #16

Closed Sjok closed 7 years ago

Sjok commented 9 years ago

I used the

venn3([A,B,C], ('AA', 'BB','CC'))

where A and B and C are sets. But it does not show the len(A \interset B -C) I mean I have len(A \interset B -C)=35 but in venn give me nothing so len(A \interset B -C)=0? Could you please give me some help?

konstantint commented 9 years ago

In general, if your data is skewed to the point that the circles are positioned so that the region corresponding to AB~C is not visible (e.g. because other regions are too large in comparison), the corresponding number will not be shown indeed.

Alternatively, it may be a bug, but to diagnose it I'd need to see the actual data.

snownontrace commented 9 years ago

I have exactly the same issue. I think the reason is as you said, the region corresponding to one region is totally invisible so that it was not labeled/shown at all... Is it possible to make ellipse or some other shapes so that the overlapping regions are always visible?

konstantint commented 9 years ago

Indeed, drawing a Venn diagram with ellipses instead of circles would increase its degrees of freedom and make it possible to avoid such situations. However, designing an algorithm for reasonably pretty ellipse-venn positioning and subsequent clipping is an endeavor worthy of a separate project for which I myself do not have the time or motivation at the moment. In fact, before attempting this, one should develop a general Bezier-shape intersection library for Python, it is still missing and without it implementing ellipse-ellipse intersection would be a pain.

The best what one may probably expect to do to solve the "missing region" problem for circle-based Venn diagrams is to come up with a way to position the label of such a region even though the region itself would be missing or empty. Unfortunately, it is also not trivial. In the current solution the geometric shape of each region (computed as the appropriate intersection of circles) is used as the basis for finding a proper label position within that shape. But if there is no shape, there is no place to put the label and some ad-hoc techniques should be applied in order to "invent" the label position out of nothing.

I am keeping this issue open to collect particular examples of such corner cases. Once there are enough of them I (or why not someone else) might look into adding some ad-hoc tricks for preserving the labels of the "disappeared" regions, which would solve at least the known problem samples.

Before that happens, you should resort to manual hacks. At least two are possible:

snownontrace commented 9 years ago

I added some annotation manually after creating the Venn. It's not so hard to notice that something is missing, since 2 of the 3 circles are not overlapping at all. I'll wait for someone who's more competent in Python than I (e.g. you or someone else) to develop a more sophisticated way...

konstantint commented 9 years ago

It would be nice if you could show the numbers that you used to demonstrate the problem.

konstantint commented 7 years ago

Duplicate of #30