I'm using python package matplotlib_venn to plot venn diagram. I want to set the size of the circles such that in different plots the circle size will be the same. How could I do it?
from charticle.venn import Venn2
import matplotlib_venn as vplt
import matplotlib.pyplot as plt
fig = plt.figure()
plt.subplot(121)
v2 = vplt.venn2(subsets={'10':10,'01':10,'11':1},set_labels = ('A','B'))
v.Sizes(a=1.0, b=10.0, ab=1.0)
plt.subplot(122)
v1 = vplt.venn2(subsets={'10':10,'01':1000,'11':1},set_labels = ('A','B'))
plt.show()

How's this? I mostly worked with the venn2_circles objects and ignored the venn2 ones. If you try to color in with the venn2 object, the radii will be off and it won't fill properly, which is what I think the comment above was mentioning.
import matplotlib_venn as vplt
import matplotlib.pyplot as plt
plt.figure(figsize=(10,10))
plt.subplot(1, 2, 1)
plt.title('Subplot 1')
v = vplt.venn2(subsets=(10,10,1), set_labels=('A', 'B'), set_colors=('w', 'w'))
c = vplt.venn2_circles(subsets=(2, 2, 1), linestyle='solid')
c[0].set_radius(0.32)
c[1].set_radius(0.32)
c[0].set_lw(2.0)
c[1].set_lw(2.0)
c[0].set_color('green')
c[1].set_color('red')
c[0].set_alpha(0.5)
c[1].set_alpha(0.5)
c[0].set_edgecolor('black')
c[1].set_edgecolor('black')
plt.subplot(1, 2, 2)
plt.title('Subplot 2')
v = vplt.venn2(subsets=(10,1000,1), set_labels=('A', 'B'), set_colors=('w', 'w'))
v.get_label_by_id('10').set_x(0.25)
v.get_label_by_id('01').set_x(-.25)
v.get_label_by_id('11').set_x(0)
v.set_labels[0].set_position((-0.22, -0.45))
v.set_labels[1].set_position((0.25, -0.45))
c = vplt.venn2_circles(subsets=(2, 2, 1), linestyle='solid')
c[0].set_radius(0.32)
c[1].set_radius(0.32)
c[0].set_lw(2.0)
c[1].set_lw(2.0)
c[0].set_color('green')
c[1].set_color('red')
c[0].set_alpha(0.5)
c[1].set_alpha(0.5)
c[0].set_edgecolor('black')
c[1].set_edgecolor('black')
Picture of result here because I need 10 reputation to post pictures
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With