Closed Sjok closed 7 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.
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?
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:
annotate
, or text
command, guessing the appropriate coordinates by trial and error).You can draw the diagram using tweaked numbers, such that the necessary region is not missing, and then manually change the text in the corresponding label to the correct number. Suppose your current subset sizes are (k,l,m,n,o,p,q), and suppose that the subregion "AB not C" (with size m) is not shown on the diagram due to bad skew in favor of other regions. If you artificially increase the size of that region (from m to, say, m+100 or m+1000) chances are at some point it will appear on the diagram. You can then change the label of that region to the correct value. I.e.:
v = venn3((k,l,m + 100,n,o,p,q))
v.get_label_by_id('110').set_text(m)
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...
It would be nice if you could show the numbers that you used to demonstrate the problem.
Duplicate of #30
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?