LankyCyril / pyvenn

Python module for plotting Venn diagrams of 2..6 sets
https://pypi.org/project/venn
GNU General Public License v3.0
121 stars 27 forks source link

non-interactive/batch example to image file? #5

Closed chickenandpork closed 5 years ago

chickenandpork commented 5 years ago

Can you create or describe an example that produces an image file? I'd like to leverage your work to quickly produce diagrams, but I'm not a matplot user, and I don't see where any file is written out.

For context, I tried:

pip3 install --user venn 
grep -v '^%' your-minimal-musician-example | tee musician.py
  from venn import venn

 musicians = {
     "Members of The Beatles": {"Paul McCartney", "John Lennon", "George Harrison", "Ringo Starr"},
     "Guitarists": {"John Lennon", "George Harrison", "Jimi Hendrix", "Eric Clapton", "Carlos Santana"},
     "Played at Woodstock": {"Jimi Hendrix", "Carlos Santana", "Keith Moon"}
  }
  venn(musicians)

python3 musician.py

The file runs once the %matplotlib inline is removed, but the result doesn't export the generated object as an image. Perhaps it's trying to manipulate a running matplot process?

LankyCyril commented 5 years ago

Hi! In a non-interactive environment you can use the Axes object returned by the venn() function:

ax = venn(musicians)
ax.figure.savefig("musicians.png", bbox_inches="tight")

When run inside the notebook, jupyter just recognizes that an Axes object has been returned and displays it.