使用 matplotlib-venn 在维恩图上设置圆圈大小和标签大小 [英] set circle size and label size on venn diagram with matplotlib-venn
问题描述
我使用 matplotlib-venn 库创建了几个不同的维恩图,它们共享至少一组.我希望该集合的圆圈在两者上具有相同的大小,因此它们具有可比性.我还想更改标签字体的大小,但我还不了解如何从matplotlib-venn函数中获取字体.我怎么办?
I have a couple of different Venn diagrams created with matplotlib-venn library, which share at least one set. I would like the circle of that set to be of the same size on both, so they are comparable. I would also like to change the size of the font of the labels, but I don't understand yet how to get that from the matplotlib-venn functions. How could I do it?
集合的一个例子可能是这样的:
an example of the sets could be something like this:
from matplotlib_venn import venn3
s1=set('abracadabra')
s2=set('alakazam')
s3=set('stackoverflow')
s4=set('hocus pocus')
v_test1=venn3([s1,s2,s3],('set1','set2','set3'))
v_test1=venn3([s1,s3,s4],('set1','set3','set4'))
推荐答案
当你调用 venn3
函数时,它会调用 solve_venn3_circles
来计算圆心和半径.这意味着您不能自己设置半径,因为它会影响最终图像,并且可能不正确.但是,您可以尝试通过 venn3
函数的 normalize_to
参数来调整圆圈的大小.
When you call venn3
function it call solve_venn3_circles
to calculate centers and radius of circles. It is mean that you can not set radius by yourself because it is affect the final image and it may be incorrect. However you may try to adjust your circles' size by normalize_to
argument of venn3
function.
对于字体大小,您可以使用以下代码:
For font size you can use this code:
for t in v_test1.set_labels: t.set_fontsize(22)
for t in v_test1.subset_labels: t.set_fontsize(20)
或者通过 id 设置字体大小:
Or set font size by id:
label = v_test1.get_label_by_id('111')
label.set_fontsize(22)
有关 ID 信息,请查找手册页.
For id information look for manual page.
这篇关于使用 matplotlib-venn 在维恩图上设置圆圈大小和标签大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!