File tree 1 file changed +22
-4
lines changed
1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change 5
5
6
6
Allowing text input with the Textbox widget.
7
7
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.
11
15
"""
12
16
13
17
import numpy as np
22
26
23
27
24
28
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 )
26
32
l .set_ydata (ydata )
27
33
ax .set_ylim (np .min (ydata ), np .max (ydata ))
28
34
plt .draw ()
@@ -32,3 +38,15 @@ def submit(text):
32
38
text_box .on_submit (submit )
33
39
34
40
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
You can’t perform that action at this time.
0 commit comments