Strategy to make 2 Graphics on one same Panel "Synchronized"

Hi Everyone,

i have 3 Waves and they are "Time", "CV1" and "CV2", and then i maked a panel with 2 graphics (each graphic in its own subwindow), plane#graphic1 displays CV1 vs Time, and plane#graphic2 displays CV2 vs Time.

Here is my question, how can i make these 2 Graphics synchronized? I mean, the axis for x value could be changed together when i use e.g. "Expand" or "Autoscale Axis".

I thought the best way to solve this is with the window hook function. I tried to detect event "Modified"(case 8 ) in a subwindow and then use "SetAxis" to change the other graphic, but it doesn't work. The Manual shows me this event(Modified) sents to graph and notebook windows only, if it means "modified" will not work for a graphic-subwindow on a panel ?

Then i tired to use the "Menu Detection", e.g. detect the "Expand" in Menu "GraphMarquee", i thought the MenuName is "GraphMarquee" and MenuItem is "Expand", but it returns nothing.

I thought i may have something wrong with my Strategy or something else, so any suggestion or idea will be very appreciated.

Sorry for my English.

Have a Nice Day!
Make one graph. Put the the first curve on as normal. Use a new y axis for the second curve but keep the same x axis. Split the plot to have the first y axis from 0-50% and the second from 50-100%.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
Thank you jjweimer!

That is really a alternative solution and i will try it.

But i stll want to ask, is it possible to do this on a panel with subwindows?
There is probably a much better way of doing it that this, but here is some demonstration code of something that nearly works:
Function Test()
    Make/O/N=10 CV1,CV2
    CV1[]=cos(p)
    CV2[]=sin(p)
    NewPanel/N=plane /W=(100,100,700,600)
    Display/HOST=plane/N=Graph1/W=(10,10,590,240) CV1
    Display/HOST=plane/N=Graph2/W=(10,260,590,490) CV2
    SetWindow plane,hook(AxisHook)=MyHook
End
Function MyHook(s)
    STRUCT WMWinHookStruct &s
    Variable hookResult = 0
    switch(s.eventCode)
        case 22:        // MouseWheel
        case 4:     // MouseMoved
        case 5:     // MouseUp
            string sOtherWin
            if(cmpStr(s.WinName,"plane#Graph1")==0)
                sOtherWin="plane#Graph2"
            elseif(cmpStr(s.WinName,"plane#Graph2")==0)
                sOtherWin="plane#Graph1"
            else
                break
            endif
            string sCmd="GetSetAxes(\""+s.WinName+"\",\""+sOtherWin+"\")"
            Execute/P/Q/Z sCmd
            break
    endswitch
    return hookResult       // 0 if nothing done, else 1
End
Function GetSetAxes(sWin1,sWin2)
    string sWin1
    string sWin2
    GetAxis/W=$sWin1/Q bottom
    SetAxis/W=$sWin2 bottom,V_min,V_max
End

One problem with this is if one context-clicks to autoscale, and the mouseup on the autoscale option is outside the graph, then it does not apply the SetAxis function.
However, I hope this helps a little, even if it is quite clunky!
Rgds,
Kurt
apirls wrote:
I thought the best way to solve this is with the window hook function. I tried to detect event "Modified"(case 8 ) in a subwindow and then use "SetAxis" to change the other graphic, but it doesn't work. The Manual shows me this event(Modified) sents to graph and notebook windows only, if it means "modified" will not work for a graphic-subwindow on a panel ?

Hm. I tried a quick test of this method. It seems like the best bet for making this work. But I found that the Modified event winName member is the root window (like Graph1) not the subwindow graph that was modified (like Graph1#G0). That's not helpful, and makes it pretty nearly impossible to make that technique work. I'm going to talk to the engineer responsible...
Quote:
Sorry for my English.

Your English is much better than any foreign language I have ever tried to learn! It was not a problem.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
KurtB wrote:
There is probably a much better way of doing it that this, but here is some demonstration code of something that nearly works:


Hi KurtB, thank you so much for this excellnet and awesome idea. It is very helpful, i will try and see if i can avoid the "misunderstand" context.

Good Day!
johnweeks wrote:

I'm going to talk to the engineer responsible...

Thanks for your help, Johnweeks. If there is any suggestion, could you please post it? It will be very grateful!

Good Day!
It turns out that the internal architecture simply doesn't support getting the subwindow name for the Modified event. So the best solution is to not use subwindows, but use the Draw Between settings to create a stacked graph with two vertical axes and just one X axis.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com