Venn3: How to reposition circles and labels?

天涯浪子 提交于 2019-12-03 15:11:14

What is the code to move the circle labels (i.e."Set1","Set2","Set3") because right now one is too far away from the circle.

Something like that:

lbl = vd.get_label_by_id("A")
x, y = lbl.get_position()
lbl.set_position((x+0.1, y-0.2))  # Or whatever

The "A", "B", and "C" are predefined identifiers, denoting the three sets.

What is the code to make the circles be three equal sizes/change the circle size?

If you do not want the circle/region sizes to correspond to your data (not necessarily a good idea), you can get an unweighted ("classical") Venn diagram using the function venn3_unweighted:

from matplotlib_venn import venn3_unweighted 
venn3_unweighted(...same parameters you used in venn3...)

You can further cheat and tune the result by providing a subset_areas parameter to venn3_unweighted - this is a seven-element vector specifying the desired relative size of each region. In this case the diagram will be drawn as if the region areas were subset_areas, yet the numbers will be shown from the actual subsets. Try, for example:

venn3_unweighted(...., subset_areas=(10,1,1,1,1,1,1))

What is the code to move the circles around the plot.

The need to "move the circles around" is somewhat unusual - normally you would either want the circles to be positioned so that their intersection sizes correspond to your data, or use the "default" positioning. The functions venn3 and venn3_unweighted cater to those two requirements. Moving circles around arbitrarily is possible, but would require some lower-level coding and I'd advice against that.

I found it difficult to find what the commands such as "set_x", "set_alpha" should be

The object you get when you call v.get_label_by_id is a Matplotlib Text object. You can read about its methods and properties here. The object returned by v.get_patch_by_id is a PathPatch, look here and here for reference.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!