数据可视化之美

python 画venn图

2022-02-01  本文已影响0人  11的雾

python 画韦恩图
安装pyvenn
pip3 install pyvenn

需要导入两个包:
from venn import venn
from matplotlib import pyplot as plt

将数据存储成为字典类型
venn_dict = {a : {'a','b','c'}, b:{'c','d','e'}}

直接调用venn函数,不需要注明是几个圈。
venn(venn_dict)
plt.savefig("venn.png", dpi=300)


image.png

其他参数:
cmap:可以是一个matplotlib colormap的名称,也可以是一个颜色名称列表。
fmt:是一个Python 3风格的格式字符串,可以解释{size}, {percentage}和{logic}。
alpha:设置透明度
fontsize:字体大小,整数型 fontsize=3,
legend_loc:图例位置。默认为“右上角”;如果需要完全禁用图例,则通过legend_loc=None。
figsize:仅在ax=None时有效;否则,图将被绘制到一个现有的轴上,图的大小将被忽略。

更多venn图画法:

R 画Venn图:【小工具】R 画venn图 二个三个四个五个都能画

上一篇 下一篇

猜你喜欢

热点阅读