Arrange Left Axes
hrodstein
// ArrangeLeftAxes(graphName)
// graphName contains the name of a graph to which you have appended waves using one or more free left axes.
// ArrangeLeftAxes arranges the left axes to allocate the available vertical space evenly.
// For a demo execute the Demo function below.
static Function ArrangeLeftAxes(graphName)
String graphName // "" for top graph
if (strlen(graphName) == 0)
graphName = WinName(0, 1)
if (strlen(graphName) == 0)
return -1 // No graphs - should not happen
endif
endif
String leftAxisList = AxisList(graphName)
leftAxisList = ReplaceString("bottom;", leftAxisList, "")
Variable numLeftAxes = ItemsInList(leftAxisList)
if (numLeftAxes == 0)
return 0 // There are no waves selected for display
endif
if (CmpStr(leftAxisList, "left;") == 0)
return 0 // We are not stacking traces so there is nothing to do
endif
Variable groutSize = .05
Variable numGrouts = numLeftAxes - 1
// Determine the percentage of plot area height to allocate to each left axis
Variable leftAxisLength = 1.00
if (numLeftAxes > 1)
leftAxisLength = (1.00 - numGrouts*groutSize) / numLeftAxes
endif
Variable leftAxisStart = 0
Variable i
for(i=0; i<numLeftAxes; i+=1)
String leftAxisName = StringFromList(i, leftAxisList)
ModifyGraph /W=$graphName axisEnab($leftAxisName)={leftAxisStart,leftAxisStart+leftAxisLength}
ModifyGraph /W=$graphName freePos($leftAxisName)=0
leftAxisStart += leftAxisLength + groutSize
ModifyGraph /W=$graphName lblPosMode($leftAxisName)=2, lblMargin($leftAxisName)=5 // Label stays near left edge of graph window
endfor
End
Function Demo()
DoWindow /K DemoGraph // Kill graph if it already exists
Make /O wave0 = sin(x/8)
Make /O wave1 = cos(x/8)
Make /O wave2 = wave0 * wave1
Display /N=DemoGraph /W=(35,44,832,530) /L=left0 wave0
AppendToGraph /L=left1 wave1
AppendToGraph /L=left2 wave2
ArrangeLeftAxes("DemoGraph")
End
// graphName contains the name of a graph to which you have appended waves using one or more free left axes.
// ArrangeLeftAxes arranges the left axes to allocate the available vertical space evenly.
// For a demo execute the Demo function below.
static Function ArrangeLeftAxes(graphName)
String graphName // "" for top graph
if (strlen(graphName) == 0)
graphName = WinName(0, 1)
if (strlen(graphName) == 0)
return -1 // No graphs - should not happen
endif
endif
String leftAxisList = AxisList(graphName)
leftAxisList = ReplaceString("bottom;", leftAxisList, "")
Variable numLeftAxes = ItemsInList(leftAxisList)
if (numLeftAxes == 0)
return 0 // There are no waves selected for display
endif
if (CmpStr(leftAxisList, "left;") == 0)
return 0 // We are not stacking traces so there is nothing to do
endif
Variable groutSize = .05
Variable numGrouts = numLeftAxes - 1
// Determine the percentage of plot area height to allocate to each left axis
Variable leftAxisLength = 1.00
if (numLeftAxes > 1)
leftAxisLength = (1.00 - numGrouts*groutSize) / numLeftAxes
endif
Variable leftAxisStart = 0
Variable i
for(i=0; i<numLeftAxes; i+=1)
String leftAxisName = StringFromList(i, leftAxisList)
ModifyGraph /W=$graphName axisEnab($leftAxisName)={leftAxisStart,leftAxisStart+leftAxisLength}
ModifyGraph /W=$graphName freePos($leftAxisName)=0
leftAxisStart += leftAxisLength + groutSize
ModifyGraph /W=$graphName lblPosMode($leftAxisName)=2, lblMargin($leftAxisName)=5 // Label stays near left edge of graph window
endfor
End
Function Demo()
DoWindow /K DemoGraph // Kill graph if it already exists
Make /O wave0 = sin(x/8)
Make /O wave1 = cos(x/8)
Make /O wave2 = wave0 * wave1
Display /N=DemoGraph /W=(35,44,832,530) /L=left0 wave0
AppendToGraph /L=left1 wave1
AppendToGraph /L=left2 wave2
ArrangeLeftAxes("DemoGraph")
End
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More