[
  {
    "path": ".gitignore",
    "content": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packaging\n.Python\nenv/\nbuild/\ndevelop-eggs/\ndist/\ndownloads/\neggs/\n.eggs/\nlib/\nlib64/\nparts/\nsdist/\nvar/\n*.egg-info/\n.installed.cfg\n*.egg\n\n# PyInstaller\n#  Usually these files are written by a python script from a template\n#  before PyInstaller builds the exe, so as to inject date/other infos into it.\n*.manifest\n*.spec\n\n# Installer logs\npip-log.txt\npip-delete-this-directory.txt\n\n# Unit test / coverage reports\nhtmlcov/\n.tox/\n.coverage\n.coverage.*\n.cache\nnosetests.xml\ncoverage.xml\n*,cover\n.hypothesis/\n\n# Translations\n*.mo\n*.pot\n\n# Django stuff:\n*.log\n\n# Sphinx documentation\ndocs/_build/\n\n# PyBuilder\ntarget/\n\n#Ipython Notebook\n.ipynb_checkpoints\n"
  },
  {
    "path": "LICENSE",
    "content": "This is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to <http://unlicense.org>\n"
  },
  {
    "path": "README.md",
    "content": "# pyvenn\n2 ~ 6 Sets Venn Diagram For Python\n\nCheckout this repository first:\n```python\ngit clone https://github.com/tctianchi/pyvenn.git\ncd pyvenn\n```\n\nUse magic function in an ipython notebook:\n```python\n%matplotlib inline\n\nimport venn\n```\n\nOr use a non-interactive backend:\n```python\nimport matplotlib\nmatplotlib.use('Agg')\n\nimport venn\n```\n\nFetch labels for each subset of the venn diagram. The input argument is an array of iterable data(list, set, etc.). You will get a mapping table, where \"10\" indicates the number of elements in set 1 but not in set 2, \"01\" indicates the number of elements in set 2 but not in set 1, and so on.\n```python\nIn [5]: labels = venn.get_labels([\n            range(10),\n            range(5, 15)\n        ], fill=['number', 'logic'])\nIn [6]: print labels\nOut [6]: {'01': '01: 5', '10': '10: 5', '11': '11: 5'}\n```\n\nPlot functions are based on the labels:\n```python\nfig, ax = venn.venn2(labels, names=['list 1', 'list 2'])\nfig.show()\n```\n\n![venn2](https://raw.githubusercontent.com/wiki/tctianchi/pyvenn/venn2.png)\n\nMore examples:\n```python\nlabels = venn.get_labels([range(10), range(5, 15), range(3, 8)], fill=['number', 'logic'])\nfig, ax = venn.venn3(labels, names=['list 1', 'list 2', 'list 3'])\nfig.show()\n```\n\n![venn3](https://raw.githubusercontent.com/wiki/tctianchi/pyvenn/venn3.png)\n\n```python\nlabels = venn.get_labels([range(10), range(5, 15), range(3, 8), range(8, 17)], fill=['number', 'logic'])\nfig, ax = venn.venn4(labels, names=['list 1', 'list 2', 'list 3', 'list 4'])\nfig.show()\n```\n\n![venn4](https://raw.githubusercontent.com/wiki/tctianchi/pyvenn/venn4.png)\n\n```python\nlabels = venn.get_labels([range(10), range(5, 15), range(3, 8), range(8, 17), range(10, 20)], fill=['number', 'logic'])\nfig, ax = venn.venn5(labels, names=['list 1', 'list 2', 'list 3', 'list 4', 'list 5'])\nfig.show()\n```\n\n![venn5](https://raw.githubusercontent.com/wiki/tctianchi/pyvenn/venn5.png)\n\n```python\nlabels = venn.get_labels([range(10), range(5, 15), range(3, 8), range(8, 17), range(10, 20), range(13, 25)], fill=['number', 'logic'])\nfig, ax = venn.venn6(labels, names=['list 1', 'list 2', 'list 3', 'list 4', 'list 5', 'list 6'])\nfig.show()\n```\n\n![venn6](https://raw.githubusercontent.com/wiki/tctianchi/pyvenn/venn6.png)\n"
  },
  {
    "path": "__init__.py",
    "content": ""
  },
  {
    "path": "demo.py",
    "content": "# coding: utf-8\n\n# ipython notebook requires this\n# %matplotlib inline\n\n# python console requires this\nimport matplotlib\nmatplotlib.use('Agg')\n\nimport matplotlib.pyplot as plt\nimport venn\n\nlabels = venn.get_labels([range(10), range(5, 15)], fill=['number', 'logic'])\nfig, ax = venn.venn2(labels, names=['list 1', 'list 2'])\nfig.savefig('venn2.png', bbox_inches='tight')\nplt.close()\n\nlabels = venn.get_labels([range(10), range(5, 15), range(3, 8)], fill=['number', 'logic'])\nfig, ax = venn.venn3(labels, names=['list 1', 'list 2', 'list 3'])\nfig.savefig('venn3.png', bbox_inches='tight')\nplt.close()\n\nlabels = venn.get_labels([range(10), range(5, 15), range(3, 8), range(8, 17)], fill=['number', 'logic'])\nfig, ax = venn.venn4(labels, names=['list 1', 'list 2', 'list 3', 'list 4'])\nfig.savefig('venn4.png', bbox_inches='tight')\nplt.close()\n\nlabels = venn.get_labels([range(10), range(5, 15), range(3, 8), range(8, 17), range(10, 20)], fill=['number', 'logic'])\nfig, ax = venn.venn5(labels, names=['list 1', 'list 2', 'list 3', 'list 4', 'list 5'])\nfig.savefig('venn5.png', bbox_inches='tight')\nplt.close()\n\nlabels = venn.get_labels([range(10), range(5, 15), range(3, 8), range(8, 17), range(10, 20), range(13, 25)], fill=['number', 'logic'])\nfig, ax = venn.venn6(labels, names=['list 1', 'list 2', 'list 3', 'list 4', 'list 5', 'list 6'])\nfig.savefig('venn6.png', bbox_inches='tight')\nplt.close()\n\n"
  },
  {
    "path": "venn.py",
    "content": "# coding: utf-8\nfrom itertools import chain\ntry:\n    # since python 3.10\n    from collections.abc import Iterable\nexcept ImportError:\n    from collections import Iterable\nimport matplotlib.pyplot as plt\nimport matplotlib.patches as patches\nfrom matplotlib import colors\nimport math\n\ndefault_colors = [\n    # r, g, b, a\n    [92, 192, 98, 0.5],\n    [90, 155, 212, 0.5],\n    [246, 236, 86, 0.6],\n    [241, 90, 96, 0.4],\n    [255, 117, 0, 0.3],\n    [82, 82, 190, 0.2],\n]\ndefault_colors = [\n    [i[0] / 255.0, i[1] / 255.0, i[2] / 255.0, i[3]]\n    for i in default_colors\n]\n\ndef draw_ellipse(fig, ax, x, y, w, h, a, fillcolor):\n    e = patches.Ellipse(\n        xy=(x, y),\n        width=w,\n        height=h,\n        angle=a,\n        color=fillcolor)\n    ax.add_patch(e)\n\ndef draw_triangle(fig, ax, x1, y1, x2, y2, x3, y3, fillcolor):\n    xy = [\n        (x1, y1),\n        (x2, y2),\n        (x3, y3),\n    ]\n    polygon = patches.Polygon(\n        xy=xy,\n        closed=True,\n        color=fillcolor)\n    ax.add_patch(polygon)\n\ndef draw_text(fig, ax, x, y, text, color=[0, 0, 0, 1], fontsize=14, ha=\"center\", va=\"center\"):\n    ax.text(\n        x, y, text,\n        horizontalalignment=ha,\n        verticalalignment=va,\n        fontsize=fontsize,\n        color=\"black\")\n\ndef draw_annotate(fig, ax, x, y, textx, texty, text, color=[0, 0, 0, 1], arrowcolor=[0, 0, 0, 0.3]):\n    plt.annotate(\n        text,\n        xy=(x, y),\n        xytext=(textx, texty),\n        arrowprops=dict(color=arrowcolor, shrink=0, width=0.5, headwidth=8),\n        fontsize=14,\n        color=color,\n        xycoords=\"data\",\n        textcoords=\"data\",\n        horizontalalignment='center',\n        verticalalignment='center'\n    )\n\ndef get_labels(data, fill=[\"number\"]):\n    \"\"\"\n    get a dict of labels for groups in data\n\n    @type data: list[Iterable]\n    @rtype: dict[str, str]\n\n    input\n      data: data to get label for\n      fill: [\"number\"|\"logic\"|\"percent\"]\n\n    return\n      labels: a dict of labels for different sets\n\n    example:\n    In [12]: get_labels([range(10), range(5,15), range(3,8)], fill=[\"number\"])\n    Out[12]:\n    {'001': '0',\n     '010': '5',\n     '011': '0',\n     '100': '3',\n     '101': '2',\n     '110': '2',\n     '111': '3'}\n    \"\"\"\n\n    N = len(data)\n\n    sets_data = [set(data[i]) for i in range(N)]  # sets for separate groups\n    s_all = set(chain(*data))                     # union of all sets\n\n    # bin(3) --> '0b11', so bin(3).split('0b')[-1] will remove \"0b\"\n    set_collections = {}\n    for n in range(1, 2**N):\n        key = bin(n).split('0b')[-1].zfill(N)\n        value = s_all\n        sets_for_intersection = [sets_data[i] for i in range(N) if  key[i] == '1']\n        sets_for_difference = [sets_data[i] for i in range(N) if  key[i] == '0']\n        for s in sets_for_intersection:\n            value = value & s\n        for s in sets_for_difference:\n            value = value - s\n        set_collections[key] = value\n\n    labels = {k: \"\" for k in set_collections}\n    if \"logic\" in fill:\n        for k in set_collections:\n            labels[k] = k + \": \"\n    if \"number\" in fill:\n        for k in set_collections:\n            labels[k] += str(len(set_collections[k]))\n    if \"percent\" in fill:\n        data_size = len(s_all)\n        for k in set_collections:\n            labels[k] += \"(%.1f%%)\" % (100.0 * len(set_collections[k]) / data_size)\n\n    return labels\n\ndef venn2(labels, names=['A', 'B'], **options):\n    \"\"\"\n    plots a 2-set Venn diagram\n\n    @type labels: dict[str, str]\n    @type names: list[str]\n    @rtype: (Figure, AxesSubplot)\n\n    input\n      labels: a label dict where keys are identified via binary codes ('01', '10', '11'),\n              hence a valid set could look like: {'01': 'text 1', '10': 'text 2', '11': 'text 3'}.\n              unmentioned codes are considered as ''.\n      names:  group names\n      more:   colors, figsize, dpi, fontsize\n\n    return\n      pyplot Figure and AxesSubplot object\n    \"\"\"\n    colors = options.get('colors', [default_colors[i] for i in range(2)])\n    figsize = options.get('figsize', (9, 7))\n    dpi = options.get('dpi', 96)\n    fontsize = options.get('fontsize', 14)\n\n    fig = plt.figure(0, figsize=figsize, dpi=dpi)\n    ax = fig.add_subplot(111, aspect='equal')\n    ax.set_axis_off()\n    ax.set_ylim(bottom=0.0, top=0.7)\n    ax.set_xlim(left=0.0, right=1.0)\n\n    # body\n    draw_ellipse(fig, ax, 0.375, 0.3, 0.5, 0.5, 0.0, colors[0])\n    draw_ellipse(fig, ax, 0.625, 0.3, 0.5, 0.5, 0.0, colors[1])\n    draw_text(fig, ax, 0.74, 0.30, labels.get('01', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.26, 0.30, labels.get('10', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.50, 0.30, labels.get('11', ''), fontsize=fontsize)\n\n    # legend\n    draw_text(fig, ax, 0.20, 0.56, names[0], colors[0], fontsize=fontsize, ha=\"right\", va=\"bottom\")\n    draw_text(fig, ax, 0.80, 0.56, names[1], colors[1], fontsize=fontsize, ha=\"left\", va=\"bottom\")\n    leg = ax.legend(names, loc='center left', bbox_to_anchor=(1.0, 0.5), fancybox=True)\n    leg.get_frame().set_alpha(0.5)\n\n    return fig, ax\n\ndef venn3(labels, names=['A', 'B', 'C'], **options):\n    \"\"\"\n    plots a 3-set Venn diagram\n\n    @type labels: dict[str, str]\n    @type names: list[str]\n    @rtype: (Figure, AxesSubplot)\n\n    input\n      labels: a label dict where keys are identified via binary codes ('001', '010', '100', ...),\n              hence a valid set could look like: {'001': 'text 1', '010': 'text 2', '100': 'text 3', ...}.\n              unmentioned codes are considered as ''.\n      names:  group names\n      more:   colors, figsize, dpi, fontsize\n\n    return\n      pyplot Figure and AxesSubplot object\n    \"\"\"\n    colors = options.get('colors', [default_colors[i] for i in range(3)])\n    figsize = options.get('figsize', (9, 9))\n    dpi = options.get('dpi', 96)\n    fontsize = options.get('fontsize', 14)\n\n    fig = plt.figure(0, figsize=figsize, dpi=dpi)\n    ax = fig.add_subplot(111, aspect='equal')\n    ax.set_axis_off()\n    ax.set_ylim(bottom=0.0, top=1.0)\n    ax.set_xlim(left=0.0, right=1.0)\n\n    # body\n    draw_ellipse(fig, ax, 0.333, 0.633, 0.5, 0.5, 0.0, colors[0])\n    draw_ellipse(fig, ax, 0.666, 0.633, 0.5, 0.5, 0.0, colors[1])\n    draw_ellipse(fig, ax, 0.500, 0.310, 0.5, 0.5, 0.0, colors[2])\n    draw_text(fig, ax, 0.50, 0.27, labels.get('001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.73, 0.65, labels.get('010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.61, 0.46, labels.get('011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.27, 0.65, labels.get('100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.39, 0.46, labels.get('101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.50, 0.65, labels.get('110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.50, 0.51, labels.get('111', ''), fontsize=fontsize)\n\n    # legend\n    draw_text(fig, ax, 0.15, 0.87, names[0], colors[0], fontsize=fontsize, ha=\"right\", va=\"bottom\")\n    draw_text(fig, ax, 0.85, 0.87, names[1], colors[1], fontsize=fontsize, ha=\"left\", va=\"bottom\")\n    draw_text(fig, ax, 0.50, 0.02, names[2], colors[2], fontsize=fontsize, va=\"top\")\n    leg = ax.legend(names, loc='center left', bbox_to_anchor=(1.0, 0.5), fancybox=True)\n    leg.get_frame().set_alpha(0.5)\n\n    return fig, ax\n\ndef venn4(labels, names=['A', 'B', 'C', 'D'], **options):\n    \"\"\"\n    plots a 4-set Venn diagram\n\n    @type labels: dict[str, str]\n    @type names: list[str]\n    @rtype: (Figure, AxesSubplot)\n\n    input\n      labels: a label dict where keys are identified via binary codes ('0001', '0010', '0100', ...),\n              hence a valid set could look like: {'0001': 'text 1', '0010': 'text 2', '0100': 'text 3', ...}.\n              unmentioned codes are considered as ''.\n      names:  group names\n      more:   colors, figsize, dpi, fontsize\n\n    return\n      pyplot Figure and AxesSubplot object\n    \"\"\"\n    colors = options.get('colors', [default_colors[i] for i in range(4)])\n    figsize = options.get('figsize', (12, 12))\n    dpi = options.get('dpi', 96)\n    fontsize = options.get('fontsize', 14)\n\n    fig = plt.figure(0, figsize=figsize, dpi=dpi)\n    ax = fig.add_subplot(111, aspect='equal')\n    ax.set_axis_off()\n    ax.set_ylim(bottom=0.0, top=1.0)\n    ax.set_xlim(left=0.0, right=1.0)\n\n    # body\n    draw_ellipse(fig, ax, 0.350, 0.400, 0.72, 0.45, 140.0, colors[0])\n    draw_ellipse(fig, ax, 0.450, 0.500, 0.72, 0.45, 140.0, colors[1])\n    draw_ellipse(fig, ax, 0.544, 0.500, 0.72, 0.45, 40.0, colors[2])\n    draw_ellipse(fig, ax, 0.644, 0.400, 0.72, 0.45, 40.0, colors[3])\n    draw_text(fig, ax, 0.85, 0.42, labels.get('0001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.68, 0.72, labels.get('0010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.77, 0.59, labels.get('0011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.32, 0.72, labels.get('0100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.71, 0.30, labels.get('0101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.50, 0.66, labels.get('0110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.65, 0.50, labels.get('0111', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.14, 0.42, labels.get('1000', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.50, 0.17, labels.get('1001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.29, 0.30, labels.get('1010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.39, 0.24, labels.get('1011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.23, 0.59, labels.get('1100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.61, 0.24, labels.get('1101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.35, 0.50, labels.get('1110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.50, 0.38, labels.get('1111', ''), fontsize=fontsize)\n\n    # legend\n    draw_text(fig, ax, 0.13, 0.18, names[0], colors[0], fontsize=fontsize, ha=\"right\")\n    draw_text(fig, ax, 0.18, 0.83, names[1], colors[1], fontsize=fontsize, ha=\"right\", va=\"bottom\")\n    draw_text(fig, ax, 0.82, 0.83, names[2], colors[2], fontsize=fontsize, ha=\"left\", va=\"bottom\")\n    draw_text(fig, ax, 0.87, 0.18, names[3], colors[3], fontsize=fontsize, ha=\"left\", va=\"top\")\n    leg = ax.legend(names, loc='center left', bbox_to_anchor=(1.0, 0.5), fancybox=True)\n    leg.get_frame().set_alpha(0.5)\n\n    return fig, ax\n\ndef venn5(labels, names=['A', 'B', 'C', 'D', 'E'], **options):\n    \"\"\"\n    plots a 5-set Venn diagram\n\n    @type labels: dict[str, str]\n    @type names: list[str]\n    @rtype: (Figure, AxesSubplot)\n\n    input\n      labels: a label dict where keys are identified via binary codes ('00001', '00010', '00100', ...),\n              hence a valid set could look like: {'00001': 'text 1', '00010': 'text 2', '00100': 'text 3', ...}.\n              unmentioned codes are considered as ''.\n      names:  group names\n      more:   colors, figsize, dpi, fontsize\n\n    return\n      pyplot Figure and AxesSubplot object\n    \"\"\"\n    colors = options.get('colors', [default_colors[i] for i in range(5)])\n    figsize = options.get('figsize', (13, 13))\n    dpi = options.get('dpi', 96)\n    fontsize = options.get('fontsize', 14)\n\n    fig = plt.figure(0, figsize=figsize, dpi=dpi)\n    ax = fig.add_subplot(111, aspect='equal')\n    ax.set_axis_off()\n    ax.set_ylim(bottom=0.0, top=1.0)\n    ax.set_xlim(left=0.0, right=1.0)\n\n    # body\n    draw_ellipse(fig, ax, 0.428, 0.449, 0.87, 0.50, 155.0, colors[0])\n    draw_ellipse(fig, ax, 0.469, 0.543, 0.87, 0.50, 82.0, colors[1])\n    draw_ellipse(fig, ax, 0.558, 0.523, 0.87, 0.50, 10.0, colors[2])\n    draw_ellipse(fig, ax, 0.578, 0.432, 0.87, 0.50, 118.0, colors[3])\n    draw_ellipse(fig, ax, 0.489, 0.383, 0.87, 0.50, 46.0, colors[4])\n    draw_text(fig, ax, 0.27, 0.11, labels.get('00001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.72, 0.11, labels.get('00010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.55, 0.13, labels.get('00011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.91, 0.58, labels.get('00100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.78, 0.64, labels.get('00101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.84, 0.41, labels.get('00110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.76, 0.55, labels.get('00111', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.51, 0.90, labels.get('01000', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.39, 0.15, labels.get('01001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.42, 0.78, labels.get('01010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.50, 0.15, labels.get('01011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.67, 0.76, labels.get('01100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.70, 0.71, labels.get('01101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.51, 0.74, labels.get('01110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.64, 0.67, labels.get('01111', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.10, 0.61, labels.get('10000', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.20, 0.31, labels.get('10001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.76, 0.25, labels.get('10010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.65, 0.23, labels.get('10011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.18, 0.50, labels.get('10100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.21, 0.37, labels.get('10101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.81, 0.37, labels.get('10110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.74, 0.40, labels.get('10111', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.27, 0.70, labels.get('11000', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.34, 0.25, labels.get('11001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.33, 0.72, labels.get('11010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.51, 0.22, labels.get('11011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.25, 0.58, labels.get('11100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.28, 0.39, labels.get('11101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.36, 0.66, labels.get('11110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.51, 0.47, labels.get('11111', ''), fontsize=fontsize)\n\n    # legend\n    draw_text(fig, ax, 0.02, 0.72, names[0], colors[0], fontsize=fontsize, ha=\"right\")\n    draw_text(fig, ax, 0.72, 0.94, names[1], colors[1], fontsize=fontsize, va=\"bottom\")\n    draw_text(fig, ax, 0.97, 0.74, names[2], colors[2], fontsize=fontsize, ha=\"left\")\n    draw_text(fig, ax, 0.88, 0.05, names[3], colors[3], fontsize=fontsize, ha=\"left\")\n    draw_text(fig, ax, 0.12, 0.05, names[4], colors[4], fontsize=fontsize, ha=\"right\")\n    leg = ax.legend(names, loc='center left', bbox_to_anchor=(1.0, 0.5), fancybox=True)\n    leg.get_frame().set_alpha(0.5)\n\n    return fig, ax\n\ndef venn6(labels, names=['A', 'B', 'C', 'D', 'E', 'F'], **options):\n    \"\"\"\n    plots a 6-set Venn diagram\n\n    @type labels: dict[str, str]\n    @type names: list[str]\n    @rtype: (Figure, AxesSubplot)\n\n    input\n      labels: a label dict where keys are identified via binary codes ('000001', '000010', '000100', ...),\n              hence a valid set could look like: {'000001': 'text 1', '000010': 'text 2', '000100': 'text 3', ...}.\n              unmentioned codes are considered as ''.\n      names:  group names\n      more:   colors, figsize, dpi, fontsize\n\n    return\n      pyplot Figure and AxesSubplot object\n    \"\"\"\n    colors = options.get('colors', [default_colors[i] for i in range(6)])\n    figsize = options.get('figsize', (20, 20))\n    dpi = options.get('dpi', 96)\n    fontsize = options.get('fontsize', 14)\n\n    fig = plt.figure(0, figsize=figsize, dpi=dpi)\n    ax = fig.add_subplot(111, aspect='equal')\n    ax.set_axis_off()\n    ax.set_ylim(bottom=0.230, top=0.845)\n    ax.set_xlim(left=0.173, right=0.788)\n\n    # body\n    # See https://web.archive.org/web/20040819232503/http://www.hpl.hp.com/techreports/2000/HPL-2000-73.pdf\n    draw_triangle(fig, ax, 0.637, 0.921, 0.649, 0.274, 0.188, 0.667, colors[0])\n    draw_triangle(fig, ax, 0.981, 0.769, 0.335, 0.191, 0.393, 0.671, colors[1])\n    draw_triangle(fig, ax, 0.941, 0.397, 0.292, 0.475, 0.456, 0.747, colors[2])\n    draw_triangle(fig, ax, 0.662, 0.119, 0.316, 0.548, 0.662, 0.700, colors[3])\n    draw_triangle(fig, ax, 0.309, 0.081, 0.374, 0.718, 0.681, 0.488, colors[4])\n    draw_triangle(fig, ax, 0.016, 0.626, 0.726, 0.687, 0.522, 0.327, colors[5])\n    draw_text(fig, ax, 0.212, 0.562, labels.get('000001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.430, 0.249, labels.get('000010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.356, 0.444, labels.get('000011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.609, 0.255, labels.get('000100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.323, 0.546, labels.get('000101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.513, 0.316, labels.get('000110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.523, 0.348, labels.get('000111', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.747, 0.458, labels.get('001000', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.325, 0.492, labels.get('001001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.670, 0.481, labels.get('001010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.359, 0.478, labels.get('001011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.653, 0.444, labels.get('001100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.344, 0.526, labels.get('001101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.653, 0.466, labels.get('001110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.363, 0.503, labels.get('001111', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.750, 0.616, labels.get('010000', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.682, 0.654, labels.get('010001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.402, 0.310, labels.get('010010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.392, 0.421, labels.get('010011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.653, 0.691, labels.get('010100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.651, 0.644, labels.get('010101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.490, 0.340, labels.get('010110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.468, 0.399, labels.get('010111', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.692, 0.545, labels.get('011000', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.666, 0.592, labels.get('011001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.665, 0.496, labels.get('011010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.374, 0.470, labels.get('011011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.653, 0.537, labels.get('011100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.652, 0.579, labels.get('011101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.653, 0.488, labels.get('011110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.389, 0.486, labels.get('011111', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.553, 0.806, labels.get('100000', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.313, 0.604, labels.get('100001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.388, 0.694, labels.get('100010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.375, 0.633, labels.get('100011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.605, 0.359, labels.get('100100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.334, 0.555, labels.get('100101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.582, 0.397, labels.get('100110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.542, 0.372, labels.get('100111', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.468, 0.708, labels.get('101000', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.355, 0.572, labels.get('101001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.420, 0.679, labels.get('101010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.375, 0.597, labels.get('101011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.641, 0.436, labels.get('101100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.348, 0.538, labels.get('101101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.635, 0.453, labels.get('101110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.370, 0.548, labels.get('101111', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.594, 0.689, labels.get('110000', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.579, 0.670, labels.get('110001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.398, 0.670, labels.get('110010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.395, 0.653, labels.get('110011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.633, 0.682, labels.get('110100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.616, 0.656, labels.get('110101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.587, 0.427, labels.get('110110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.526, 0.415, labels.get('110111', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.495, 0.677, labels.get('111000', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.505, 0.648, labels.get('111001', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.428, 0.663, labels.get('111010', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.430, 0.631, labels.get('111011', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.639, 0.524, labels.get('111100', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.591, 0.604, labels.get('111101', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.622, 0.477, labels.get('111110', ''), fontsize=fontsize)\n    draw_text(fig, ax, 0.501, 0.523, labels.get('111111', ''), fontsize=fontsize)\n\n    # legend\n    draw_text(fig, ax, 0.674, 0.824, names[0], colors[0], fontsize=fontsize)\n    draw_text(fig, ax, 0.747, 0.751, names[1], colors[1], fontsize=fontsize)\n    draw_text(fig, ax, 0.739, 0.396, names[2], colors[2], fontsize=fontsize)\n    draw_text(fig, ax, 0.700, 0.247, names[3], colors[3], fontsize=fontsize)\n    draw_text(fig, ax, 0.291, 0.255, names[4], colors[4], fontsize=fontsize)\n    draw_text(fig, ax, 0.203, 0.484, names[5], colors[5], fontsize=fontsize)\n    leg = ax.legend(names, loc='center left', bbox_to_anchor=(1.0, 0.5), fancybox=True)\n    leg.get_frame().set_alpha(0.5)\n\n    return fig, ax\n\n"
  }
]