Quick and dirt tool for swapping Y axes.

I all too frequently add a trace to a graph with two different Y-axes and add it to the wrong one.    Below is a procedure that adds a menu to the right-click popup to swap the axes.  After right-clicking a trace, click the bottom menu item.  The initial stuff is "borrowed" from the manual.  Put it in your local user procedures folder.

 

#pragma TextEncoding = "UTF-8"
#pragma rtGlobals=3     // Use modern global access method and strict wave access.

Menu "TracePopup", dynamic
    TraceClickerPosition(), /Q, TraceClicker()
end

function /s TraceClickerPosition()
   
    getmouse /W=kwTopWin
    variable /G V_TraceMenuX=V_left
    return "Swap left and right Y axis"
end

function TraceClicker()
 
    // figure out graph and trace names
    GetLastUserMenuInfo
 
    // figure out mouse position within graph on SECOND click
    getmouse /W=$S_graphName  
    string s_info=traceinfo(S_graphName, S_traceName, 0)
    string s_xwave=stringbykey("XWAVE",s_info)
    string s_yaxis=stringbykey("YAXIS",s_info)

    RemoveFromGraph $S_tracename
    if (CmpStr(s_yaxis, "left")==0)
        // delete this curve and re-add it on the right
        AppendToGraph/R $s_tracename vs $s_xwave
    else
        // delete this curve and re-add it on the left
        AppendToGraph/L $s_tracename vs $s_xwave
    endif

    return 1
end

 

FWIW, Igor 8 and later already have this feature built-in--right click on a trace and select "Move to Opposite Axis".