With the following code I tried to create the Venn diagram then saved as a file.
import matplotlib
from matplotlib_venn import venn2
set1 = set(['A', 'B', 'C', 'D'])
set2 = set(['B', 'C', 'D', 'E'])
plt = venn2([set1,set2],('Set1','Set2'))
plt.savefig('test.png')
But it gave me error. What's the right way to do it?
This is the example figure where I exceuted under Ipython:
venn2
is a function that returns an instance of VennDiagram
.
However, the class VennDiagram
does not have the method savefig as you wish.
What you are trying to do is to save the resulting figure. For that, based on your loaded modules, you can use the following command.
matplotlib.pyplot.savefig('test.png')
instead of
plt.savefig('test.png')
This might solve the problem for you.
Cheers