With the following code:
from matplotlib import pyplot as plt
from matplotlib_venn import venn2
from collections import OrderedDict
named_sets = {'x1': set(['foo','foo','bar',"pax"]), "x3" : set(['foo','qux','bar',"zoo"])}
od = OrderedDict(sorted(named_sets.iteritems()))
circlenm = ()
circlels = []
for k,v in od.iteritems():
circlenm = circlenm + (k,)
circlels.append(v)
c = venn2(subsets = circlels,set_labels = circlenm)
c.get_patch_by_id('10').set_color('red')
c.get_patch_by_id('01').set_color('blue')
c.get_patch_by_id('10').set_edgecolor('none')
c.get_patch_by_id('01').set_edgecolor('none')
c.get_patch_by_id('10').set_alpha(0.4)
c.get_patch_by_id('01').set_alpha(0.4)
plt.show()
I can get the following figure:
Here I'd like to blend circles of 'blue' with 'red'. Notice that the result of the blending is brown.
But the actual value supposed to be light magenta (figure below is created using default matplotlib_venn.venn3
):
How can I achieve that correctly?
Add these 3 lines to set the color and display properties of the intersection:
c.get_patch_by_id('11').set_color('magenta')
c.get_patch_by_id('11').set_edgecolor('none')
c.get_patch_by_id('11').set_alpha(0.4)
If you want an exact color then you can set like this:
c.get_patch_by_id('11').set_color('#e098e1')
The patch id is a bitmask showing which circles the area is inside.
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