I have a plot that is a representation of a sine wave.
In the code, I have the frequency of the sine wave represented as a variable b
. I need to be able to change b
in real time (i.e. without having to re-run the code after manually changing the value). Ideally, this could be done by using a slider. I tried to use Tkinter
's Slider
feature, but was unable to embed the plot in the Tkinter
window.
The code that generates the stimulus is as follows:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
vals = np.linspace(-np.pi,np.pi,100)
xgrid, ygrid = np.meshgrid(vals,vals)
b = 5
the_sine = np.sin(xgrid * b)
plt.imshow(the_sine)
fig = plt.imshow(the_sine, cm.gray)
plt.axis('off')
fig.axes.get_xaxis().set_visible(False)
fig.axes.get_yaxis().set_visible(False)
plt.show()
I can't include an image of the plot, but if you run the code, you'll see how this is a little different than adjusting the parameters of something like a simple line.
Any suggestions?