Skip to content

Commit 51784a9

Browse files
committed
add more comments. add a reference section
1 parent 3b2a898 commit 51784a9

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

examples/widgets/textbox.py

+22-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
66
Allowing text input with the Textbox widget.
77
8-
You can use the Textbox widget to let users provide any text that needs to be
9-
displayed, including formulas. You can use a submit button to create plots
10-
with the given input.
8+
You can use the Textbox widget to let users interactively provide any text
9+
that needs to be displayed, including formulas. You can use a submit button to
10+
create plots with the given input.
11+
12+
Note to not get confused with
13+
:doc:`/tutorials/text/annotations` and
14+
:doc:`/gallery/recipes/placing_text_boxes`, both of which are static elements.
1115
"""
1216

1317
import numpy as np
@@ -22,7 +26,9 @@
2226

2327

2428
def submit(text):
25-
ydata = eval(text)
29+
# user can enter a new math expression that uses "t" as its independent
30+
# variable. The plot refreshes on entering. Example: try "t ** 3"
31+
ydata = eval(text)
2632
l.set_ydata(ydata)
2733
ax.set_ylim(np.min(ydata), np.max(ydata))
2834
plt.draw()
@@ -32,3 +38,15 @@ def submit(text):
3238
text_box.on_submit(submit)
3339

3440
plt.show()
41+
42+
#############################################################################
43+
#
44+
# ------------
45+
#
46+
# References
47+
# """"""""""
48+
#
49+
# The use of the following functions, methods, classes and modules is shown
50+
# in this example:
51+
52+
from matplotlib.widgets import TextBox

0 commit comments

Comments
 (0)