Skip to content

Commit

Permalink
add demos to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tctianchi committed Apr 14, 2016
1 parent caec1f3 commit 3e29575
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 3 deletions.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,68 @@
# pyvenn
2 ~ 6 Sets Venn Diagram For Python

Use magic function in ipython notebook:
```python
%matplotlib inline

import venn
```

Or using non-interactive backend:
```python
import matplotlib
matplotlib.use('Agg')

import venn
```

Fetch labels of each subset in venn diagram. The input data is an array of iterable data(list, set, etc.).
```python
In [5]: labels = venn.get_labels([
range(10),
range(5, 15)
], fill=['number', 'logic'])
In [6]: print labels
Out [6]: {'01': '01: 5', '10': '10: 5', '11': '11: 5'}
```

And plot:
```python
fig, ax = venn.venn2(labels, names=['list 1', 'list 2'])
fig.show()
```

![venn2](https://raw.githubusercontent.com/wiki/tctianchi/pyvenn/venn2.png)

More examples:
```python
labels = venn.get_labels([range(10), range(5, 15), range(3, 8)], fill=['number', 'logic'])
fig, ax = venn.venn3(labels, names=['list 1', 'list 2', 'list 3'])
fig.show()
```

![venn3](https://raw.githubusercontent.com/wiki/tctianchi/pyvenn/venn3.png)

```python
labels = venn.get_labels([range(10), range(5, 15), range(3, 8), range(8, 17)], fill=['number', 'logic'])
fig, ax = venn.venn4(labels, names=['list 1', 'list 2', 'list 3', 'list 4'])
fig.show()
```

![venn4](https://raw.githubusercontent.com/wiki/tctianchi/pyvenn/venn4.png)

```python
labels = venn.get_labels([range(10), range(5, 15), range(3, 8), range(8, 17), range(10, 20)], fill=['number', 'logic'])
fig, ax = venn.venn5(labels, names=['list 1', 'list 2', 'list 3', 'list 4', 'list 5'])
fig.show()
```

![venn5](https://raw.githubusercontent.com/wiki/tctianchi/pyvenn/venn5.png)

```python
labels = venn.get_labels([range(10), range(5, 15), range(3, 8), range(8, 17), range(10, 20), range(13, 25)], fill=['number', 'logic'])
fig, ax = venn.venn6(labels, names=['list 1', 'list 2', 'list 3', 'list 4', 'list 5', 'list 6'])
fig.show()
```

![venn6](https://raw.githubusercontent.com/wiki/tctianchi/pyvenn/venn6.png)
6 changes: 3 additions & 3 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
# python console requires this
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

import matplotlib.pyplot as plt
import venn

labels = venn.get_labels([range(10), range(5,15)], fill=['number', 'logic'])
fig, ax = venn.venn2(labels, names=['List 1', 'List 2'])
labels = venn.get_labels([range(10), range(5, 15)], fill=['number', 'logic'])
fig, ax = venn.venn2(labels, names=['list 1', 'list 2'])
fig.savefig('venn2.png', bbox_inches='tight')
plt.close()

Expand Down

0 comments on commit 3e29575

Please sign in to comment.