konstantint / matplotlib-venn

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

4-way venns? #15

Open lbergelson opened 9 years ago

lbergelson commented 9 years ago

Hi,

I love this package, it's fantastic. I was wondering if you had any plans to extend it to 4-way venns as well. (Or know of a good python package for that?) As far as I know, proportional 4-way venns are not possible with circles or elipses, but even non-proportional ones would be quite useful.

Louis

konstantint commented 9 years ago

Yes, I will probably add the non-area-weighted 4-set diagram eventually by borrowing the layout from this implementation. It does not split the diagram into separate regions, otherwise you'll get quite decent 4-ellipse fixed diagram there. Try it.

I must note, however, that I personally find that the 4-circle case is already visually too complex and not as useful.

lbergelson commented 9 years ago

Thanks for sharing that. That's exactly the sort of layout I was thinking of.

naskokam commented 8 years ago

Hi Konstantin,

thanks for the great work! I was also interested in a 4-way Venn diagram function and wanted to ask if that will be available soon.

Best regards, Atanas

konstantint commented 8 years ago

As you might note, so far I am kind-of putting this issue off indefinitely so far (hoping perhaps someone else might step up). Let's say I'll try to convince myself to implement that within a couple of next months.

The link above to the venn.py implementation seems to be outdated. An alternative link to the same file would be: https://github.com/ksahlin/pyinfor/blob/master/venn.py

OceanWolf commented 7 years ago

Hi Konstantin, nice project, I take it that "within a couple of next months" hasn't happened yet? What stumbling blocks do you face with this and how much work do you think it would need?

I have taken a quick look at the Venn wiki page and it looks interesting, but I guess the maths involved gets quite challenging (I prefer applied maths over pure).

From what I gather from my quick glance, this package doesn't create Venn diagrams but Euler diagrams which I think I prefer as it seems to get rid of extraneous data and thus makes it easier to read.

This has made me thinking, as this package draws Euler diagrams, then do you see it as a possibility to generalise the API to construct an N-set Euler diagram where the sets happen to simplify and if not throw a NotimplementedError. As an example of what I mean, I see from examples (I haven't poked around in the code yet), that a venn3 with one of the sets having no intersection with the other 2 will draw what looks like a venn2 diagram with a separate circle for the lone set.

A generic N-set API would for example detect if the sets exist as a collection of lone-set, venn2, and venn3 diagrams and if not, throw a not implemented error.

A further step of implementing more complex diagrams would involve identifying chains, i.e. expanding beyond diagrams such as:

import matplotlib.pyplot as plt
from matplotlib_venn import venn3

set1 = set(['A', 'B', 'C'])
set2 = set(['C', 'D', 'E'])
set3 = set(['E', 'F', 'G'])
venn3([set1, set2, set3], ('Set1', 'Set2', 'Set3'))
plt.show()

Another (in theory) simple N-set case, with further expansion to "Set1" and "Set3" getting replaced by venn3s, slowly ebbing away at cases which would throw the NotImplementedError.

What do you think?

konstantint commented 7 years ago

Yes, you are right - I still did not find the time to implement the four-way venn. One of the reasons is that, well, there just do not seem to be too much demand for that, nor would anyone want to step in.

You may call the diagrams Euler-diagrams. I don't think the terminology really matters here as long as people understand what is meant. I personally am used to calling these diagrams Venn, even if they are weighted or do not include some of the zero-size subsets.

I was considering making an N-set diagram visualization, indeed, however this would require a more complicated general optimization procedure for laying out the circles and a completely different graphics engine instead of the ad-hoc circle intersections I am computing in my code (something based on shapely perhaps and supporting arbitrary Bezier curve intersections).

Implementing an ad-hoc "chain-detection" method which would only work on some datasets does not seem very useful to me (at least not as long as I see a large set of use cases for these particular cases).

Anyway, as far as this particular task is concerned, what needs to be done is a rewrite of the existing code with four ellipses with an added function which splits the ellipses into the respective patches. My current ad-hoc approach for computing patch geometry is painful to generalize as it would require hand-specifying all the arcs. Relying on shapely instead would make things much easier I guess.

leandromaroni commented 4 years ago

It would be so great that the 4-way venn diagram was done, I'd collaborate if I was more than a mere beginner in Python

chitown88 commented 4 years ago

Just throwing this out there, there is a 2-6 venn diagrams available here. Also, I'd be interested in a 4-way Venn too, so. I'll look into stepping up to create that.

moritzschaefer commented 4 years ago

This R library does 4-way venns with somewhat proportional intersections: https://rdrr.io/cran/eulerr/man/plot.euler.html Maybe we can rewrite some of their logic?

ksyme99 commented 3 years ago

Just throwing this out there, there is a 2-6 venn diagrams available here. Also, I'd be interested in a 4-way Venn too, so. I'll look into stepping up to create that.

I have played with that library but unfortunately they are not particularly helpful I find, as they are more schematic and not actually proportional, which is the main benefit of this one! The maths looks horrid though for going above 3, so while I hope for it to happen, for now I shall be doing multiple venn3 with different combinations of sets!