Issue
Here is a Venn Diagram I drew in Python:
!pip install matplotlib_venn
from matplotlib_venn import venn2
import matplotlib.pyplot as plt
from matplotlib_venn import venn2
import matplotlib.pyplot as plt
set1_size = 20
set2_size = 25
intersection_size = 5
venn2(subsets=(set1_size, set2_size, intersection_size))
plt.show()
This makes a brown part, a green part and a red part.
I want to extract the green part separately, the brown part separately and the red part separately.
Is there something that can be done to do this? I tried looking but found nothing. Is it even possible?
Or is it possible to just have the venn diagram as blank color, and then just individually highlight certain parts? Ex: center as yellow, (left circle without center) as purple, etc?
Solution
Possible arguments for .get_patch_by_id()
include '10', '11', and '01'. See also this link.
See the patch documentation for other patch parameters (e.g. color) that you can set.
from matplotlib_venn import venn2
import matplotlib.pyplot as plt
set1_size = 20
set2_size = 25
intersection_size = 5
fig, ax = plt.subplots()
vd = venn2(subsets=(set1_size, set2_size, intersection_size))
vd.get_patch_by_id('10').set(visible=False, label=None)
vd.get_label_by_id('10').set_text("")
vd.get_patch_by_id('11').set(visible=False, label=None)
vd.get_label_by_id('11').set_text("")
plt.show()
Answered By - rasputin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.