File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66Allowing 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
1317import numpy as np
2226
2327
2428def 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):
3238text_box .on_submit (submit )
3339
3440plt .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