2015-04-21 81 views
3

用下面的代碼:準確的色彩混合

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() 

我可以得到如下圖所示:

enter image description here

在這裏,我想融入圈子的「藍」與'紅'。 請注意,混合的結果是棕色

但應該是淡品紅(下圖使用的是默認matplotlib_venn.venn3創建的)實際值:

enter image description here

我怎樣才能做到這一點是否正確?

回答

2

添加這些3線設置交叉口的顏色和顯示特性:

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) 

如果你想要一個精確的顏色,那麼你可以這樣設置:

c.get_patch_by_id('11').set_color('#e098e1') 

修補程序ID是顯示該區域位於哪個圈內的位掩碼。