Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 355f3a3

Browse files
committed
Added description to widget example programs except Cursor and Menu
1 parent a5c0164 commit 355f3a3

File tree

8 files changed

+62
-6
lines changed

8 files changed

+62
-6
lines changed

examples/widgets/buttons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
=======
33
Buttons
44
=======
5-
5+
An pretty cool example to show how to use buttons widget.The program shows a simple GUI with a sine wave changing its frequency.The next and previous button widget used here helps shows the wave with new frequency.
66
"""
77

88
import numpy as np

examples/widgets/check_buttons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
=============
33
Check Buttons
44
=============
5-
5+
This program shows the use of 'Check Buttons' which is similar to our usual check boxes. There are 3 different sine waves which are shown and by checking the boxes, we can choose which waves we want to see.
66
"""
77
import numpy as np
88
import matplotlib.pyplot as plt

examples/widgets/lasso_selector_demo_sgskip.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
===================
33
Lasso Selector Demo
44
===================
5+
An example to show the Lasso Selector widget. The graph shows a scatter plot. You can select a few points by drawing a lasso loop around the points on the graphjust like any other Lasso tool. To draw, just click on the graph,hold and drag it around the points you need to select.
56
67
"""
78
from __future__ import print_function

examples/widgets/multicursor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
===========
33
Multicursor
44
===========
5-
5+
An example to show multiple cursors. The graph has two subplots and on hovering over the cursor over the two seperate graphs, the values are shown respectively.
66
"""
77
import numpy as np
88
import matplotlib.pyplot as plt

examples/widgets/radio_buttons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
=============
33
Radio Buttons
44
=============
5-
5+
An example to show how radio buttons widget can be used in the plots. The radio button in this program helps you choose one of the three different sine waves to be shown in the plot.
66
"""
77
import numpy as np
88
import matplotlib.pyplot as plt

examples/widgets/slider_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
===========
33
Slider Demo
44
===========
5-
5+
An example to show the use of slider widget. In this example, slider is used to choose the frequency of the wave.
66
"""
77
import numpy as np
88
import matplotlib.pyplot as plt

examples/widgets/slider_demo1.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
===========
3+
Slider Demo
4+
===========
5+
6+
"""
7+
import numpy as np
8+
import matplotlib.pyplot as plt
9+
from matplotlib.widgets import Slider, Button, RadioButtons
10+
11+
fig, ax = plt.subplots()
12+
plt.subplots_adjust(left=0.25, bottom=0.25)
13+
t = np.arange(0.0, 1.0, 0.001)
14+
a0 = 5
15+
f0 = 3
16+
delta_f = 5.0
17+
s = a0*np.sin(2*np.pi*f0*t)
18+
l, = plt.plot(t, s, lw=2, color='red')
19+
plt.axis([0, 1, -10, 10])
20+
21+
axcolor = 'lightgoldenrodyellow'
22+
axfreq = plt.axes([0.25, 0.1, 0.65, 0.03])
23+
axamp = plt.axes([0.25, 0.15, 0.65, 0.03])
24+
25+
sfreq = Slider(axfreq, 'Freq', 0.1, 30.0, valinit=f0, valstep=delta_f)
26+
samp = Slider(axamp, 'Amp', 0.1, 10.0, valinit=a0)
27+
28+
29+
def update(val):
30+
amp = samp.val
31+
freq = sfreq.val
32+
l.set_ydata(amp*np.sin(2*np.pi*freq*t))
33+
fig.canvas.draw_idle()
34+
sfreq.on_changed(update)
35+
samp.on_changed(update)
36+
37+
resetax = plt.axes([0.8, 0.025, 0.1, 0.04])
38+
button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975')
39+
40+
41+
def reset(event):
42+
sfreq.reset()
43+
samp.reset()
44+
button.on_clicked(reset)
45+
46+
rax = plt.axes([0.025, 0.5, 0.15, 0.15], facecolor=axcolor)
47+
radio = RadioButtons(rax, ('red', 'blue', 'green'), active=0)
48+
49+
50+
def colorfunc(label):
51+
l.set_color(label)
52+
fig.canvas.draw_idle()
53+
radio.on_clicked(colorfunc)
54+
55+
plt.show()

examples/widgets/textbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
=======
33
Textbox
44
=======
5-
5+
An example to show the use of textbox widget. You can use it mention any text that needs to be displayed or formulas or values. You can further use it to take input from the user, and use a submit button to create plots using the given input(Just a use case).
66
"""
77

88
import numpy as np

0 commit comments

Comments
 (0)