konstantint / matplotlib-venn

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

venn3 diagram misses values from the set #81

Closed fallingdeeper closed 1 month ago

fallingdeeper commented 1 month ago

Hi, I am facing the issue with venn3 diagram plotting. , when I am trying to plot my 3 sets of values, diagram misses 102 values from one set (same issue also with venn3_circles), but when I am plotting with the venn3_unweighted, all of the values are present in the plot. matplotlib_venn version 1.1.1

here is an example code:

plt.figure(figsize=(10, 7)) venn3([virsorter_contigs, virsorter2_contigs, dvf_contigs], ('VirSorter', 'VirSorter2', 'DeepVirFinder'), set_colors=("#0173b2", "#de8f05", "#029e73" ), alpha=0.6) venn3_circles(subsets=(virsorter_contigs, virsorter2_contigs,dvf_contigs), linewidth=0.5)
plt.show()

Screenshot 2024-08-13 124222

image of venn3_unweghted diagram Screenshot 2024-08-13 124325

Values that are missed from I diagram are shown with blue color.

One observation that I had is when the initial data (pandas dataframe) started to have more duplicates (before its one column was converted to set of values) this issue occurs.

The intersection values (and its number) were also manually verified with .intersection(set_name_2) function

konstantint commented 1 month ago

The idea of the area-weighted venn-plot is to give a visual representation of the relative areas on the diagram. Unfortunately, three circles cannot be positioned to maintain a perfect representation of ratios of the areas and some sacrifices need to be made. The default layout algorithm in your case decided to sacrifice the smallest region (102) on your diagram simply because the other ones are so much bigger and thus carry much more weight.

If you absolutely need to see the region, you may try alternative layouts. E.g. the "unweighted one" that you just tried sacrifices all area weighting but is guaranteed to show all the regions. There are however intermediate options you can try that will lay out the circles somewhere inbetween the "unweighted" and "maximally weighted" layouts.

Here are some of the options you could try.

fallingdeeper commented 1 month ago

Thank you very much!