I would like to create a plot with a function whose parameters can be updated by a text input on the figure in allocated textboxes. Let's say it would look something like the following:
Here you input your values for a, b, c, and d and then press on the Update button to update the plot with those given parameters. Currently, I have the following, but I don't know how to connect the matplotlib.widgets.TextBox and an update button to the plot axes.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import TextBox
from matplotlib.gridspec import GridSpec
def function(x, a, b, c, d):
y = a*x**3 + b*x**2 + c*x + d
return y
x = np.linspace(0, 10, 100)
y = function(x, 2, 2, 2, 2) # Initial values for a, b, c, and d
fig = plt.figure()
gs = GridSpec(6, 5, figure=fig)
ax1 = fig.add_subplot(gs[0:4, :])
ax2 = fig.add_subplot(gs[5, 0])
ax3 = fig.add_subplot(gs[5, 1])
ax4 = fig.add_subplot(gs[5, 2])
ax5 = fig.add_subplot(gs[5, 3])
ax6 = fig.add_subplot(gs[5, 4])
ax1.plot(x,y)
I'm not sure how to make the textboxes and the update button. I have been using https://matplotlib.org/stable/gallery/widgets/textbox.html as reference, but without prevail.
I appreciate any help. Thank you.