Created
September 3, 2020 15:41
-
-
Save Carreau/7ad674d27698ad11bd4a4398b14481bf to your computer and use it in GitHub Desktop.
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 46, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import matplotlib.pyplot as plt\n", | |
"import numpy as np\n", | |
"import matplotlib.patches as patches\n", | |
"import scipy.signal as ss" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 82, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from ipywidgets import interact" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 115, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "5ccaf5dbd3944395bdea82ac5825dbc1", | |
"version_major": 2, | |
"version_minor": 0 | |
}, | |
"text/plain": [ | |
"interactive(children=(IntSlider(value=1, description='o1', max=30, min=1), IntSlider(value=15, description='o2…" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"@interact(o1=(1,30), o2=(2,30), o3=(2,30), δ=(0.5,2,0.1))\n", | |
"def sns(o1=0, o2=15, o3 = 30, s=(0, 40), δ=1):\n", | |
" fig, ax = plt.subplots()\n", | |
" x = np.linspace(0,100, num=101)\n", | |
" y = ss.gaussian(101, s)\n", | |
" xx = x[30:]\n", | |
" c = y[30-o3:-o3]+2+δ\n", | |
" b = y[30-o2:-o2]+2\n", | |
" a = y[30-o1:-o1]+2-δ\n", | |
" ax.add_artist(patches.Wedge((65, 25), r=27, theta1=0, theta2=360, width=1, transform=ax.transData, edgecolor='#1996ff', alpha=1))\n", | |
" u1 = plt.fill_between(x[30:],0 ,10*a, color='#00496f')\n", | |
" u2 = plt.fill_between(x[30:],10*a+2,10*b, color='#005eca')\n", | |
" u3 = plt.fill_between(x[30:],10*b+2,10*c, color='#1996ff')\n", | |
" u4 = plt.fill_between(x[30:],10*c+2,10*5, color='#35d3ff')\n", | |
" ax.set_axis_off()\n", | |
" ax.set_aspect('equal')\n", | |
" \n", | |
"\n", | |
" for u in u1, u2, u3, u4:\n", | |
" u.set_clip_path(patches.Circle((65, 25), radius=25, transform=ax.transData))\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.8.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment