小编Tom*_*Tom的帖子

Venn3:如何重新定位圆圈和标签?

我做了一个三向维恩图.我有三个问题似乎无法解决.

  1. 移动圆圈标签的代码是什么(即"Set1","Set2","Set3")因为现在距离圆圈太远了.

  2. 将圆圈设为三个相同尺寸/更改圆圈尺寸的代码是什么?

  3. 围绕绘图移动圆圈的代码是什么.现在,set2在set3内(但颜色不同),我希望该图看起来更像是显示维恩图的"标准"方式(即3个独立的圆圈,中间有一些重叠).

另一方面,我发现很难找到诸如"set_x","set_alpha"之类的命令; 如果有人知道一本可以通过上述问题回答的手册我会很感激,我似乎无法找到一个包含我需要的所有信息的地方.

import sys
import numpy
import scipy
from matplotlib_venn import venn3,venn3_circles
from matplotlib import pyplot as plt

#Build three lists to make 3 way venn diagram with                                                                                                                             
list_line = lambda x: set([line.strip() for line in open(sys.argv[x])])
set1,set2,set3 = list_line(1),list_line(2),list_line(3)

#Make venn diagram                                                                                                                                                             
vd = venn3([set1,set2,set3],set_labels=("Set1","Set2","Set3"))

#Colours: get the HTML codes from the net                                                                                                                                      
vd.get_patch_by_id("100").set_color("#FF8000")
vd.get_patch_by_id("001").set_color("#5858FA")
vd.get_patch_by_id("011").set_color("#01DF3A")

#Move the numbers in the circles                                                                                                                                               
vd.get_label_by_id("100").set_x(-0.55)
vd.get_label_by_id("011").set_x(0.1)

#Strength of color, 2.0 is very strong.                                                                                                                                        
vd.get_patch_by_id("100").set_alpha(0.8)
vd.get_patch_by_id("001").set_alpha(0.6)
vd.get_patch_by_id("011").set_alpha(0.8)

plt.title("Venn …
Run Code Online (Sandbox Code Playgroud)

python matplotlib venn-diagram matplotlib-venn

5
推荐指数
1
解决办法
2725
查看次数