As I am working on the data science assignment and I want to plot data visualization better so I come across the python interact. I had used the interact previously but here I am stuck in the following code.
import matplotlib.pyplot as plt
import numpy as np
def my_plot_2(t):
j_theta_1T=[5.3148,4.0691,2.9895,2.076099,1.3287,0.74739,0.3321,0.08304,0,0.08304,0.3321,0.7473,1.3287,2.076099,2.9895,4.0691,5.3148]
X_T=np.linspace(0,2,17)
plt.figure(num=0, figsize=(6, 4), dpi=80, facecolor='w', edgecolor='k')
plt.plot(X_T,j_theta_1T,'b',t,j_theta_1T[0],'ro')
plt.title('hypothesis_fixed_theta_function_of_X',fontsize=12)
plt.xlabel('theta_1',fontsize=12)
plt.ylabel('J_theta_1',fontsize=12)
plt.grid(which='both')
plt.show()
my_plot_2(0)
This what the result of the code
Here instead of my_plot_2(0)
I want to use interact(my_plot_2, t=(0,2,0.125))
to pass the multiple values for t
and then use one by one value from j_theta_1T
and use each pass value of t
to plot the red dot point to trace the curve using the button created by interact
from ipywidgets
.
how should I pick up one by one value from j_theta_1T
?