I am trying to create a dashboard with panel. I have a float slider linked to a function that outputs a dataframe. Which means the dataframe varies with a slider. Then from this dataframe i create a line plot. When i "interact" the slider with the function and display the plot, only the dataframe updates but the plot doesn't refresh. I am new to python and even more to panel and widgets, so maybe i am trying to do something way too complicated that i could do easily in another way.
import numpy as np
import pandas as pd
import panel as pn
from panel.interact import interact
slider=pn.widgets.FloatSlider(name='Slider',start=0, end=70, value=0, width=400)
def test(V):
x=np.linspace(0,85,850)
y1=[]
y=[]
for k in x:
y1.append(np.cos( 0.10995574287564276 - 0.00022913079470198672 * k**2 ))
for k in y1:
y.append((15 + V * 0.05) * k)
df=pd.DataFrame(list(zip(x, y1, y)), columns = ['X' , 'Intermediate result' , 'Y'])
return df
inter=interact(test, V = slider)
plot=test(slider.value).hvplot(x='X', y='Y')
pn.Row(pn.Column(inter),
pn.Column(plot))
Couldn't manage to update the plot, when i just pu the slider as a parameter, it won't run and when i put slider.value, it only takes the first dataframe and never updates it