Metadata-Version: 2.4
Name: yamvp
Version: 0.2
Summary: YAMVP - Yet Another Matplotlib Venn-diagram Plotter
Home-page: https://github.com/aielte-research/yamvp.git
Author: Bálint Csanády
Author-email: csbalint@protonmail.ch
License: MIT
Keywords: Venn,Venn diagram,Matplotlib,4 sets,5 sets,visualization,plotting
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: matplotlib
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

![Python 3x](https://img.shields.io/badge/python-3.x-blue.svg)
[![pypi](https://img.shields.io/pypi/v/yamvp.svg)](https://pypi.org/project/yamvp/)
# YAMVP - Yet Another Matplotlib Venn-diagram Plotter
## Overview
This module provides a function to create Matplotlib figures containing ellipse-based Venn-diagrams with up to 5 classes.

The main goal was to provide a simple interface and good looks.

For example, color mixing of the class intersections does not simply rely on alpha stacking.  

## Installation
```
pip install yamvp
```

## Basic Usage
```python
from yamvp import venn
import numpy as np

#Fill a 4-dim 2x2x2x2 array with random values
rand4 = np.random.randint(0, 1000, size=(2, 2, 2, 2))
    
#Set the value at A∩B to 42
rand4[1,1,0,0] = 42

#Create the Venn-diagram
fig = venn(rand4, ["A", "B", "C", "D"])

#save the figure
fig.savefig("rand4_demo.png", dpi=100, bbox_inches="tight")
plt.close(fig)
```
![rand4_demo](https://github.com/aielte-research/yamvp/blob/master/img/rand4_demo.png?raw=true "rand4_demo")

## n=1
```python
venn([None, "A"], ["Alpha"], outfile = "venn1_demo.png")
```
![venn1_demo](https://github.com/aielte-research/yamvp/blob/master/img/venn1_demo.png?raw=true "venn1_demo")

## n=2
```python
venn([[None, "B"], ["A", "AB"]], ["Alpha", "Beta"], outfile = "venn2_demo.png")
```
![venn2_demo](https://github.com/aielte-research/yamvp/blob/master/img/venn2_demo.png?raw=true "venn2_demo")

## n=3
```python
vals3 = [
    [[None, "C"], ["B", "BC"]],
    [["A", "AC"], ["AB", "ABC"]],
]
venn(vals3, ["Alpha", "Beta", "Gamma"], outfile = "venn3_demo.png")
```
![venn3_demo](https://github.com/aielte-research/yamvp/blob/master/img/venn3_demo.png?raw=true "venn3_demo")

## n=4
```python
vals4 = np.empty((2, 2, 2, 2), dtype=object)
for i, yA in enumerate(("", "A")):
    for j, yB in enumerate(("", "B")):
        for k, yC in enumerate(("", "C")):
            for l, yD in enumerate(("", "D")):
                vals4[i, j, k, l] = yA + yB + yC + yD
vals4[0,0,0,0] = None

venn(vals4, ["Alpha", "Beta", "Gamma", "Delta"], outfile = "venn4_demo.png")
```
![venn4_demo](https://github.com/aielte-research/yamvp/blob/master/img/venn4_demo.png?raw=true "venn4_demo")

## n=5
```python
vals5 = np.empty((2, 2, 2, 2, 2), dtype=object)
for i, yA in enumerate(("", "A")):
    for j, yB in enumerate(("", "B")):
        for k, yC in enumerate(("", "C")):
            for l, yD in enumerate(("", "D")):
                for m, yE in enumerate(("", "E")):
                    vals5[i, j, k, l, m] = yA + yB + yC + yD + yE
vals5[0,0,0,0,0] = None

venn(vals5, ["Alpha", "Beta", "Gamma", "Delta", "Epsilon"], outfile = "venn5_demo.png")
```
![venn5_demo](https://github.com/aielte-research/yamvp/blob/master/img/venn5_demo.png?raw=true "venn5_demo")

## Additional Color Mixing Options
### Average
Each intersection color is the mean of the corresponding class colors.
```python
venn(vals4, ["Alpha", "Beta", "Gamma", "Delta"], color_mixing = "average", outfile="venn4_demo_colors_average_mixing.png")
```
![venn4_demo_colors_average_mixing](https://github.com/aielte-research/yamvp/blob/master/img/venn4_demo_colors_average_mixing.png?raw=true "venn4_demo_colors_average_mixing")

### Alpha Stacking
This would happen, if we simply stacked the ellipses with opacity=0.5. The result is dependent on the order in which the ellipses are drawn. 
```python
venn(vals4, ["Alpha", "Beta", "Gamma", "Delta"], color_mixing = "alpha", outfile = "venn4_demo_colors_alpha_mixing.png")      
```
![venn4_demo_colors_alpha_mixing](https://github.com/aielte-research/yamvp/blob/master/img/venn4_demo_colors_alpha_mixing.png?raw=true "venn4_demo_colors_alpha_mixing")

### Custom Mixing Callback 
```python
def color_mix_multiply(colors):
    arr = np.stack([np.array(c, float) for c in colors], axis=0)
    return np.prod(arr, axis=0)

venn(vals4, ["Alpha", "Beta", "Gamma", "Delta"], color_mixing=color_mix_multiply, outfile="venn4_demo_colors_multiply_mixing.png", text_color="white")     
```
![venn4_demo_colors_multiply_mixing](https://github.com/aielte-research/yamvp/blob/master/img/venn4_demo_colors_multiply_mixing.png?raw=true "venn4_demo_colors_multiply_mixing")

## Custom Class Colors
```python
venn(vals3, ["Alpha", "Beta", "Gamma"], colors=["red", "green", "blue"], outfile = "venn3_demo_colors.png")
```
![venn3_demo_colors](https://github.com/aielte-research/yamvp/blob/master/img/venn3_demo_colors.png?raw=true "venn3_demo_colors")

## License
This project is licensed under the MIT License (c) 2025 Bálint Csanády, aielte-research. See the LICENSE file for details.
