Is there an order in which Igor creates graphs?

Dear Igor Users,

Since I found it rather difficult to get any short example code that makes sense I am just trying to describe the problem:

I have a do-while-loop running that screens all subfolders in a folder for the wave matching a certain numver. When the wave is found it should be appended to a subgraph within a window.
Then the loop ends and I modify the first subgraph. I am using "GetAxis" to get the axis scaling of the y-axis. Then I create two more subgraphs containing the average and standard deviation of the traces in the first graph. For the second subgraph I set the left axis to V_min and V_max created by "GetAxis" but it does not work since the values are wrong.

It seems that although all traces of the first graph should already be appended to the graph before I am modifying it, the actual appendage is done only shortly before the second subgraph is created. So what is clearly happening in the above case is that not the axis scaling of the final graph is taken but only the axis scaling when the graph is created with the very first trace!

Could somebody please explain this behaviour to me? I am looking forward to your answers.

Best regards,

Martin

PS: A very short code version that does not run would look like that:

        do // I have a certain break-statement before that works, so don't worry about that
        all_ap = WaveList(waveident, ";", "") // a string list created individually for every folder I am screening
        count = ItemsInList(all_ap)
               
        the_ap = StringFromList(ap_ident[define_offset], all_ap) //identifying the right wave
                       
        if (index==0) // first run creates an empty window...
            Display/W=(10,10,600,600) as graphname
            DoWindow/C $graphname

            Display/W=(0.05,0.01,0.95,0.33)/Host=# $the_ap //... and the first subwindow
        else
            AppendToGraph/W=$graphname#G0    $the_ap //afterwards traces are apended
        endif
       
        reftrace = dref+objname+":"+the_ap //this is a work-around to get the full path of each wave so that fwaveaverage.ipf works!
       
        t2a[index]=reftrace
                       
        SetDataFolder dfr            
        index+=1
    while(1)

// So the loop should done here, right?! As I understand it, all traces should be in the graph by now
       
    ModifyGraph/W=$graphname#G0 rgb=(0,0,0)
    GetAxis/Q left
    TextBox/C/N=text0/F=0/A=LT/E=2 "\\f01 Plotted traces "+ap_ident_name[define_offset]

           
    String list=""
    Variable il, n= numpnts(t2a)
    for(il=0; il<n; il+=1 )
        list += t2a[il]+";"
    endfor     
   
    fwaveaverage(list,"",1,1,ap_ident_name[define_offset]+"_average_w", ap_ident_name[define_offset]+"_sd")
   
    Display/W=(0.05,0.33,0.95,0.66)/Host=## $(ap_ident_name[define_offset]+"_average_w")
    ModifyGraph/W=$graphname#G1 rgb=(0,0,0)

    SetAxis left V_min, V_max //This does not work!

Wild guess:
You are missing an explicit DoUpdate after the loop as graphs are only updated after all functions are done.