Real time update on plotly Figure widget does not work

Hello Community!
I am trying to run the following code on a Jupyter notebook and visualize the plot in a single figure as the values are updated.
But either the plot doesnt update or when i force fw.show() it creates a new figure. Could you please help me to understand how to update the values in the same plot

def runKalmanFilter (A,B,C,Q,R,xmeasured):

fw = go.FigureWidget()

fw.show()

fw.add_trace(go.Scatter(
    x = [], y =  [], name = 'Prediciton',
    marker_color = 'rgba(152, 0, 0, .8)'
))

fw.add_trace(go.Scatter(
    x = [], y =  [], name = 'Estimate',
    marker_color = 'rgba(255, 182, 193, .9)'
))
# fw.update_traces(mode = 'lines+markers');

PPred =np.array( [[0.1, 0],[0, 0.1]] )# Initial first estimate
    
xEst= np.empty([2, len(xmeasured)]) # init 
xEst[0][0]= 0 # init
xEst[1][0]= 1 # init
xPred2 = xEst.copy()
for i in range(1,len(xmeasured),1):
    # PREDICTION  
    xPred, PPred = kalmanPrediction(xEst[:,i-1:i],PPred) # (2,1)
    #UPDATE
    
    K = PPred@C.T * (1/(float(C @PPred @C.T) + R)) #Kalman gain 
    y = xmeasured[i] - output(xPred) #Error
   
    xEst[:,i:i+1] =  xPred + (K*y)    #compute estimate
    xPred2[:,i:i+1] = xPred
    PPred = (np.eye(len(K)) - K @C) @ PPred # update error covariance

    T.sleep(0.3)
    # fw.data[0].x = time[:i];
    # fw.data[1].x = time[:i];
    fw.data[0].y = xPred2[0,:i]
    fw.data[1].y = xEst[0,:i]
# fw.show();
return xEst