我编写了以下代码来创建维恩图,以显示3个集合的交集。我所绘制的只是共同点的数量。我想要的是在交叉点内打印真实的A,B,C,...,而不计算它们。有办法吗?
我的代码和输出:
set1 = set(['A', 'B', 'C', 'D'])
set2 = set(['B', 'C', 'D', 'E'])
set3 = set(['C', 'D',' E', 'F', 'G'])
v=venn3([set1, set2, set3], ('Set1', 'Set2', 'Set3'))
plt.show()
我想要的是这样的:
答案 0 :(得分:1)
See https://stackoverflow.com/a/55718006/11346909
Here's a personalized demonstration:
import matplotlib.pyplot as plt
from matplotlib_venn import venn3
set1 = set(['A', 'B', 'C', 'D'])
set2 = set(['B', 'C', 'D', 'E'])
set3 = set(['C', 'D',' E', 'F', 'G'])
venn = venn3([set1, set2, set3], ('Set1', 'Set2', 'Set3'))
venn.get_label_by_id('100').set_text('\n'.join(set1-set2-set3))
venn.get_label_by_id('110').set_text('\n'.join(set1&set2-set3))
venn.get_label_by_id('010').set_text('\n'.join(set2-set3-set1))
venn.get_label_by_id('101').set_text('\n'.join(set1&set3-set2))
venn.get_label_by_id('111').set_text('\n'.join(set1&set2&set3))
venn.get_label_by_id('011').set_text('\n'.join(set2&set3-set1))
venn.get_label_by_id('001').set_text('\n'.join(set3-set2-set1))
plt.show()