Unverified Commit e9fd9849 authored by Bertrand  NÉRON's avatar Bertrand NÉRON
Browse files

add matplotlib demo

parent 7f7560c8
%% Cell type:code id:a173b63d-52c5-4ce7-8445-9104c5a225d5 tags:
``` python
%matplotlib inline
```
%% Cell type:markdown id:ac77aa2a-ab03-4d18-88dc-8bed1a231d0c tags:
This demo need ipywidgets module
```
pip install ipywidgets
```
And enabling the widget backend (see the first cell of this notbook).
%% Cell type:code id:c4504712-9c32-4198-af1e-6887e4da3acc tags:
``` python
import numpy as np
import matplotlib.pyplot as plt
import ipywidgets
from ipywidgets import interact
```
%% Cell type:markdown id:f32dbf0d-8468-4386-ac3b-520a3330c84c tags:
## doc
Link to offical ipywidget interact
https://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html
%% Cell type:markdown id:bb2ec7a4-acc8-46d0-acd5-61db4ef1d85d tags:
## first widget
%% Cell type:code id:0ca0db23-4ff5-45d6-b7c4-469cfa454013 tags:
``` python
slider = ipywidgets.IntSlider(2, min=0, max=10, step=2)
display(slider)
```
%%%% Output: display_data
%% Cell type:markdown id:03ef9efd-47be-47cb-9f93-4f64ddbf7da4 tags:
There are lot mmore widget than sliders
%% Cell type:markdown id:b89ba6db-4aa5-4964-8a05-60c0b07c0c93 tags:
## How to link widget to a figure
%% Cell type:code id:d01dab50-0b8b-4fcc-a6e8-9d0d47dcd1b6 tags:
``` python
def sinewave(c=1):
x = np.linspace(0, 2 * np.pi, 100)
y = np.sin(x*c)
plt.plot(x, y)
plt.ylabel('sin(x)')
plt.xlabel('x')
plt.title('Sinwave function')
plt.show()
slider = ipywidgets.FloatSlider(.5, min=0, max=4, step=.5)
interact(sinewave, c=slider);
```
%%%% Output: display_data
%% Cell type:code id:5e6312df-92da-40b9-8321-7b42932570fa tags:
``` python
```
%% Cell type:markdown id:1a02d93a-13dd-4cca-89cd-3d7926662506 tags:
a tutorial
https://towardsdatascience.com/bring-your-jupyter-notebook-to-life-with-interactive-widgets-bc12e03f0916
%% Cell type:code id:411ced85-689d-43a9-9ac5-4f7a69646fd8 tags:
``` python
```
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment