konstantint / matplotlib-venn

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

Add ability for matplotlib_venn to take in multisets as parameters #26

Closed alexanderwhatley closed 8 years ago

alexanderwhatley commented 8 years ago

I've been using your package for a while, and recently I tried to draw a 3 way Venn Diagram, except that all three of the sets I had had duplicate elements. It would be possible to use either of the current APIs to draw the diagram, but it would be quite tedious either way, as I would either have to enumerate the duplicate elements or something like that if I were to use the list of sets, or I would have to compute 7 different numbers. Therefore, I propose allowing the user to enter a list of multisets (collections.Counter) as input parameters as well. An example is as follows:

from collections import Counter from matplotlib_venn import venn2, venn3 import matplotlib.pyplot as plt a = Counter([1,1,1,2,2,3,4]) b = Counter([1,1,2,4,5]) c = Counter([2,2,3,3,4,4,5,5,5,5,6]) venn_1 = venn2(subsets = [a,b], set_labels = ["a", "b"]) plt.show() venn_2 = venn3(subsets = [a,b,c], set_labels = ["a", "b", "c"]) plt.show()

konstantint commented 8 years ago

Thanks! I incorporated those changes in the code, however I cherry-picked and heavily edited your commit, and it seems that github did not recognize it as a pull request merge any more. FYI, things I changed: