Problem appending second trace to graph in Panel

Hello people of Igorland!

I have a small (and strange) problem here: I'm trying to display a second trace on a graph inside a panel, but despite my attempts I can only see the first trace.

I post the code below. I get no errors on compiling nor at run-time.
The wave to be appended is a fit produced by the code below, and it is within the XY-axis range of the graph .
Despite this it does not show up. If I double click the the first (and only) trace I see, in order to "Modify Trace Appearance", then I can see in the Trace List, the second trace I want to visualize on the graph. Attempts to change "Trace Appearance" for the second trace, result in no obvious change in what the graph displays. Weirdly, SetAxis operation also seems not to work!!

Does anyone have a clue of what is wrong here?

Many thanks in advance,

R.

Function DisplayEvent()
   
    DFREF X_Limits = root:X_Limits
    DFREF DFR_Raws = root:Events:Raws
    DFREF DFR_Integrals = root:Events:Integrals
    SVAR EventName
    NVAR EventLeft
    NVAR EventRight
    NVAR EventCenter
    SVAR EventName_Int
       
    Display /HOST=MainCtrlPanel /N=RawEvent /W=(10, 30, 390, 190) DFR_Raws:$EventName
    Display /HOST=MainCtrlPanel /N=IntEvent /W=(10, 200, 390, 360) DFR_Integrals:$EventName_Int
   
    Duplicate /O DFR_Integrals:$EventName_Int TempWave
    Variable StartP = x2pnt(TempWave, EventLeft)
    Variable EndP = x2pnt(TempWave,EventCenter)
   
    Wave fit_TempWave
   
    CurveFit /M=2/W=0 Sigmoid, root:TempWave[StartP, EndP] /D
    DoWindow /F MainCtrlPanel
    SetActiveSubwindow MainCtrlPanel#IntEvent
    AppendToGraph /W=MainCtrlPanel#IntEvent root:fit_TempWave
    DoUpdate
End

Just an idea - try putting the wave declaration
Wave fit_TempWave

after the CurveFit command. The fit wave is created by the curvefit, and so does not exist until then.

Hope this helps,
Kurt
Many thanks KurtB!! I think I found the problem - but this is still not resolved.

The problem is that this function is associated with an iterative/loop process, whereby the function is called several times to display $eventName_Int and the fit_tempWave. The problem arises only the moment it enters the second cycle, and thereafter. As the function is called time and time again the traces, $EventName_Int name is always different (traces names arrive indexed), whereas currently fit_TempWave name is always the same.

This results in the fact that Display operation will refresh the trace corresponding to $EventName_Int, and display ONLY the last $EventName_Int (whatever its index is). But AppendToGraph seems not to work that way and will instead creaet additional instances of fit_TempWave as: fit_TempWave, FitTempWave#1, fit_TempWave#2, and so on.

I tried adding a  RemoveFromGraph /Z /W=MainCtrlPanel#IntEvent fit_TempWave and this has suppressed the occurrence of old instances of fit_tempWave but the new fit_tempWave is still not appearing.

Any suggestions out there?
Ok, so the Display Operation is always displaying a new graph on top of the older one, rather than refreshing it - maybe it was silly of me to expect that by having the same name Igor could think that I would be referring to exactly the same object and therefore to simply redo and update the contents of the IntEvent graph, but this is not the case.

So, all fit_tempWaves were getting "displayed" in the very first IntEvent graph, and as the Display operation kicks in, it draws the new graph on top of the old one, the new graph contains the new $EventName_Int traces, but the fit_TempWave were all being appended to the very first IntEvent graph that was created.... well, live and learn!

Many thanks!!

R.