Here is the explanation of the preceding code blocks:
- The first three steps are familiar, so we will start with the fourth step.
- def submit(text): defines the submit callback function. text is the system variable containing the expression entered in the textbox before submitting it:
- eval() is a Python function that computes the expression supplied as the argument.
- eval(text) is the result of executing the expression entered in the TextBox and assigned to the ydata variable.
- l.set_ydata(ydata) sets the new ydata to the y axis of the line object.
- ax.set_ylim(np.min(ydata), np.max(ydata)) sets the limits for the x and y axis scales with the current data.
- plt.draw() refreshes the plot.
- axbox = plt.axes([0.1, 0.05, 0.8, 0.075]) ...