{"id":13699285,"url":"https://github.com/konstantint/matplotlib-venn","last_synced_at":"2025-05-14T07:08:06.240Z","repository":{"id":5023757,"uuid":"6182557","full_name":"konstantint/matplotlib-venn","owner":"konstantint","description":"Area-weighted venn-diagrams for Python/matplotlib","archived":false,"fork":false,"pushed_at":"2025-02-25T10:50:33.000Z","size":2024,"stargazers_count":540,"open_issues_count":5,"forks_count":68,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-11T01:41:54.460Z","etag":null,"topics":["matplotlib","matplotlib-venn","plotting","python","venn","venn-diagram"],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"openshift-quickstart/cakephp-example","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/konstantint.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-10-11T23:39:46.000Z","updated_at":"2025-04-07T04:07:01.000Z","dependencies_parsed_at":"2024-06-18T12:36:54.510Z","dependency_job_id":"9e08aa7f-4d62-4b1b-adc0-5e47f6b9f349","html_url":"https://github.com/konstantint/matplotlib-venn","commit_stats":{"total_commits":55,"total_committers":8,"mean_commits":6.875,"dds":"0.19999999999999996","last_synced_commit":"ea6ac921ce7ef2d03c4cb6c568839885517c8fc6"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konstantint%2Fmatplotlib-venn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konstantint%2Fmatplotlib-venn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konstantint%2Fmatplotlib-venn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/konstantint%2Fmatplotlib-venn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/konstantint","download_url":"https://codeload.github.com/konstantint/matplotlib-venn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092652,"owners_count":22013290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matplotlib","matplotlib-venn","plotting","python","venn","venn-diagram"],"created_at":"2024-08-02T20:00:29.608Z","updated_at":"2025-05-14T07:08:06.218Z","avatar_url":"https://github.com/konstantint.png","language":"Jupyter Notebook","readme":"====================================================\nVenn diagram plotting routines for Python/Matplotlib\n====================================================\n\n.. image::  https://travis-ci.org/konstantint/matplotlib-venn.png?branch=master\n   :target: https://travis-ci.org/konstantint/matplotlib-venn\n\nRoutines for plotting area-weighted two- and three-circle venn diagrams.\n\nInstallation\n------------\n\nInstall the package as usual via ``pip``::\n\n    $ python -m pip install matplotlib-venn\n\nSince version 1.1.0 the package includes an extra \"cost based\" layout algorithm for `venn3` diagrams,\nthat relies on the `shapely` package, which is not installed as a default dependency. If you need the\nnew algorithm (or just have nothing against installing `shapely` along the way), instead do::\n\n    $ python -m pip install \"matplotlib-venn[shapely]\"\n\nIt is quite probable that `shapely` will become a required dependency eventually in one of the future versions.\n\nDependencies\n------------\n\n- ``numpy``,\n- ``scipy``,\n- ``matplotlib``,\n- ``shapely`` (optional).\n\nUsage\n-----\nThe package provides four main functions: ``venn2``,\n``venn2_circles``, ``venn3`` and ``venn3_circles``.\n\nThe functions ``venn2`` and ``venn2_circles`` accept as their only\nrequired argument a 3-element tuple ``(Ab, aB, AB)`` of subset sizes,\nand draw a two-circle venn diagram with respective region areas, e.g.::\n\n    venn2(subsets = (3, 2, 1))\n\nIn this example, the region, corresponding to subset ``A and not B`` will\nbe three times larger in area than the region, corresponding to subset ``A and B``.\n\nYou can also provide a tuple of two ``set`` or ``Counter`` (i.e. multi-set)\nobjects instead (new in version 0.7), e.g.::\n\n    venn2((set(['A', 'B', 'C', 'D']), set(['D', 'E', 'F'])))\n\nSimilarly, the functions ``venn3`` and ``venn3_circles`` take a\n7-element tuple of subset sizes ``(Abc, aBc, ABc, abC, AbC, aBC,\nABC)``, and draw a three-circle area-weighted Venn\ndiagram: \n\n.. image:: https://user-images.githubusercontent.com/13646666/87874366-96924800-c9c9-11ea-8b06-ac1336506b59.png\n\nAlternatively, a tuple of three ``set`` or ``Counter`` objects may be provided.\n\nThe functions ``venn2`` and ``venn3`` draw the diagrams as a collection of colored\npatches, annotated with text labels. The functions ``venn2_circles`` and\n``venn3_circles`` draw just the circles.\n\nThe functions ``venn2_circles`` and ``venn3_circles`` return the list of ``matplotlib.patch.Circle`` objects that may be tuned further\nto your liking. The functions ``venn2`` and ``venn3`` return an object of class ``VennDiagram``,\nwhich gives access to constituent patches, text elements, and (since\nversion 0.7) the information about the centers and radii of the\ncircles.\n\nBasic Example::\n\n    from matplotlib_venn import venn2\n    venn2(subsets = (3, 2, 1))\n\nFor the three-circle case::\n\n    from matplotlib_venn import venn3\n    venn3(subsets = (1, 1, 1, 2, 1, 2, 2), set_labels = ('Set1', 'Set2', 'Set3'))\n\nA more elaborate example::\n\n    from matplotlib import pyplot as plt\n    import numpy as np\n    from matplotlib_venn import venn3, venn3_circles\n    plt.figure(figsize=(4,4))\n    v = venn3(subsets=(1, 1, 1, 1, 1, 1, 1), set_labels = ('A', 'B', 'C'))\n    v.get_patch_by_id('100').set_alpha(1.0)\n    v.get_patch_by_id('100').set_color('white')\n    v.get_label_by_id('100').set_text('Unknown')\n    v.get_label_by_id('A').set_text('Set \"A\"')\n    c = venn3_circles(subsets=(1, 1, 1, 1, 1, 1, 1), linestyle='dashed')\n    c[0].set_lw(1.0)\n    c[0].set_ls('dotted')\n    plt.title(\"Sample Venn diagram\")\n    plt.annotate('Unknown set', xy=v.get_label_by_id('100').get_position() - np.array([0, 0.05]), xytext=(-70,-70),\n                 ha='center', textcoords='offset points', bbox=dict(boxstyle='round,pad=0.5', fc='gray', alpha=0.1),\n                 arrowprops=dict(arrowstyle='-\u003e', connectionstyle='arc3,rad=0.5',color='gray'))\n    plt.show()\n\nAn example with multiple subplots::\n\n    from matplotlib_venn import venn2, venn2_circles\n    figure, axes = plt.subplots(2, 2)\n    venn2(subsets={'10': 1, '01': 1, '11': 1}, set_labels = ('A', 'B'), ax=axes[0][0])\n    venn2_circles((1, 2, 3), ax=axes[0][1])\n    venn3(subsets=(1, 1, 1, 1, 1, 1, 1), set_labels = ('A', 'B', 'C'), ax=axes[1][0])\n    venn3_circles({'001': 10, '100': 20, '010': 21, '110': 13, '011': 14}, ax=axes[1][1])\n    plt.show()\n\nPerhaps the most common use case is generating a Venn diagram given\nthree sets of objects::\n\n    set1 = set(['A', 'B', 'C', 'D'])\n    set2 = set(['B', 'C', 'D', 'E'])\n    set3 = set(['C', 'D',' E', 'F', 'G'])\n\n    venn3([set1, set2, set3], ('Set1', 'Set2', 'Set3'))\n    plt.show()\n\nTuning the diagram layout\n-------------------------\n\nNote that for a three-circle venn diagram it is not in general\npossible to achieve exact correspondence between the required set\nsizes and region areas. The default layout algorithm aims to correctly represent:\n\n  * Relative areas of the full individual sets (A, B, C).\n  * Relative areas of pairwise intersections of sets (A\u0026B, A\u0026C, B\u0026C, not to be confused with the regions\n    A\u0026B\u0026~C, A\u0026~B\u0026C, ~A\u0026B\u0026C, on the diagram).\n\nSometimes the result is unsatisfactory and either the area weighting or the layout logic needs\nto be tuned.\n\nThe area weighing can be adjusted by providing a `fixed_subset_sizes` argument to the `DefaultLayoutAlgorithm`::\n\n    from matplotlib_venn.layout.venn2 import DefaultLayoutAlgorithm\n    venn2((1,2,3), layout_algorithm=DefaultLayoutAlgorithm(fixed_subset_sizes=(1,1,1)))\n\n    from matplotlib_venn.layout.venn3 import DefaultLayoutAlgorithm\n    venn3((7,6,5,4,3,2,1), layout_algorithm=DefaultLayoutAlgorithm(fixed_subset_sizes=(1,1,1,1,1,1,1)))\n\nIn the above examples the diagram regions will be plotted as if `venn2((1,1,1))` and `venn3((1,1,1,1,1,1,1))` were\ninvoked, yet the actual numbers will be `(1,2,3)` and `(7,6,5,4,3,2,1)` respectively.\n\nThe diagram can be tuned further by switching the layout algorithm to a different implementation.\nAt the moment the package offers an alternative layout algorithm for `venn3` diagrams that lays the circles out by\noptimizing a user-provided *cost function*. The following examples illustrate its usage::\n\n    from matplotlib_venn.layout.venn3 import cost_based\n    subset_sizes = (100,200,10000,10,20,3,1)\n    venn3(subset_sizes, layout_algorithm=cost_based.LayoutAlgorithm())\n\n    alg = cost_based.LayoutAlgorithm(cost_fn=cost_based.WeightedAggregateCost(transform_fn=lambda x: x))\n    venn3(subset_sizes, layout_algorithm=alg)\n\n    alg = cost_based.LayoutAlgorithm(cost_fn=cost_based.WeightedAggregateCost(weights=(0,0,0,1,1,1,1)))\n    venn3(subset_sizes, layout_algorithm=alg)\n\nThe default \"pairwise\" algorithm is, theoretically, a special case of the cost-based method with the respective cost function::\n\n    alg = cost_based.LayoutAlgorithm(cost_fn=cost_based.pairwise_cost)\n    venn3(subset_sizes, layout_algorithm=alg)\n\n(The latter plot will be close, but not perfectly equal to the outcome of `DefaultLayoutAlgorithm()`).\n\nNote that the import::\n\n    from matplotlib_venn.layout.venn3 import cost_based\n\nwill fail unless you have the optional `shapely` package installed (see \"Installation\" above).\n\n\nQuestions\n---------\n\n* If you ask your questions at `StackOverflow \u003chttp://stackoverflow.com/\u003e`_ and tag them \n  `matplotlib-venn \u003chttp://stackoverflow.com/questions/tagged/matplotlib-venn\u003e`_, chances are high you could get\n  an answer from the maintainer of this package.\n\nSee also\n--------\n\n* Report issues and submit fixes at Github:\n  https://github.com/konstantint/matplotlib-venn\n  \n  Check out the ``DEVELOPER-README.rst`` for development-related notes.\n* Some alternative means of plotting a Venn diagram (as of\n  October 2012) are reviewed in the blog post:\n  http://fouryears.eu/2012/10/13/venn-diagrams-in-python/\n* The `matplotlib-subsets\n  \u003chttps://pypi.python.org/pypi/matplotlib-subsets\u003e`_ package\n  visualizes a hierarchy of sets as a tree of rectangles.\n* The `matplotlib_set_diagrams \u003chttps://pypi.org/project/matplotlib-set-diagrams\u003e`_ package\n  is a GPL-licensed alternative that offers a different layout algorithm, which supports more than\n  three sets and provides a cool ability to incorporate wordclouds into your Venn (Euler) diagrams.\n\n","funding_links":[],"categories":["\u003cspan id=\"head9\"\u003e2.4. Data Visualization\u003c/span\u003e","Visualization"],"sub_categories":["Venn Diagrams"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonstantint%2Fmatplotlib-venn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonstantint%2Fmatplotlib-venn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonstantint%2Fmatplotlib-venn/lists"}