-
Notifications
You must be signed in to change notification settings - Fork 0
/
Widgets.py
26 lines (23 loc) · 844 Bytes
/
Widgets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from matplotlib.widgets import Slider
import matplotlib.pyplot as plt
def slider(f, init=10, minval=1, maxval=20, valstep=1):
# Make a vertically oriented slider to control the amplitude
axsize = plt.axes([0.07, 0.18, 0.022, 0.5], facecolor='#00ceec')
size_slider = Slider(
ax=axsize,
label="n",
color='#005784',
valstep=valstep,
valmin=minval,
valmax=maxval,
valinit=init,
orientation="vertical"
)
size_slider.label.set_color('#00ceec')
size_slider.label.set_size(20)
size_slider.valtext.set_color('#00ceec')
size_slider.valtext.set_size(20)
# The function to be called anytime a slider's value changes
# register the update function with each slider
size_slider.on_changed(f)
return axsize, size_slider