Last active
June 20, 2019 17:15
-
-
Save fomightez/5575a91be88955257ba1f658ff253197 to your computer and use it in GitHub Desktop.
venn3 demo that will work in a cell of a Jupyter notebook --- try `%matplotlib inline`as first line instead if using JupyterLab Binder end of 2016
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%matplotlib notebook | |
from matplotlib import pyplot as plt | |
from matplotlib_venn import venn3, venn3_circles | |
#**REQUIRES `matplotlib_venn` ADDED TO `REQUIREMENTS.TXT` FOR BINDER, or run `%pip install matplotlib_venn` first** | |
#**One already set like that can be launched from https://github.com/fomightez/vpython-jupyter *** | |
# NOTE: I corrected the Subset labels according to info I posted at | |
# http://matthiaseisen.com/pp/patterns/p0145/ , which is | |
# where this code was adapted from | |
# Subset sizes | |
s = ( | |
2, # Abc | |
3, # aBc | |
4, # ABc | |
3, # abC | |
1, # AbC | |
0.5, # aBC | |
4, # ABC | |
) | |
v = venn3(subsets=s, set_labels=('A', 'B', 'C')) | |
# Subset labels | |
v.get_label_by_id('100').set_text('Abc') | |
v.get_label_by_id('010').set_text('aBc') | |
v.get_label_by_id('110').set_text('ABc') | |
v.get_label_by_id('001').set_text('abC') | |
v.get_label_by_id('101').set_text('AbC') | |
v.get_label_by_id('011').set_text('aBC') | |
v.get_label_by_id('111').set_text('ABC') | |
# Subset colors | |
v.get_patch_by_id('100').set_color('c') | |
v.get_patch_by_id('010').set_color('#993333') | |
v.get_patch_by_id('110').set_color('blue') | |
# Subset alphas | |
v.get_patch_by_id('101').set_alpha(0.4) | |
v.get_patch_by_id('011').set_alpha(1.0) | |
v.get_patch_by_id('111').set_alpha(0.7) | |
# Border styles | |
c = venn3_circles(subsets=s, linestyle='solid') | |
c[0].set_ls('dotted') # Line style | |
c[1].set_ls('dashed') | |
c[2].set_lw(1.0) # Line width | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment