@@ -1742,9 +1742,11 @@ static Function SF_CommonWindowSetup(string win, string graph)
17421742 DoWindow / T $ win, newTitle
17431743End
17441744
1745- static Function SF_GatherAxisLabels ( WAVE /WAVE formulaResults, string explicitLbl, WAVE /T axisLabels)
1745+ static Function SF_GatherAxisLabels ( WAVE /WAVE formulaResults, string explicitLbl, string formulaLabel, WAVE /T axisLabels)
17461746
17471747 variable i , size, numData
1748+ string unit
1749+
17481750 size = DimSize ( axisLabels, ROWS)
17491751 if ( ! isEmpty ( explicitLbl))
17501752 Redimension / N= ( size + 1 ) axisLabels
@@ -1760,9 +1762,29 @@ static Function SF_GatherAxisLabels(WAVE/WAVE formulaResults, string explicitLbl
17601762 if ( ! WaveExists ( wvResultY))
17611763 continue
17621764 endif
1763- // fallback to the y data unit
1764- axisLabels[ size] = WaveUnits ( wvResultY, COLS)
1765- size += 1
1765+
1766+ strswitch ( formulaLabel)
1767+ case "FORMULAY" :
1768+ unit = WaveUnits ( wvResultY, COLS)
1769+ break
1770+ case "FORMULAX" :
1771+ WAVE /Z wvResultX = formulaResults[ i ][ % FORMULAX]
1772+ if ( WaveExists ( wvResultX))
1773+ unit = WaveUnits ( wvResultX, ROWS)
1774+ else
1775+ unit = WaveUnits ( wvResultY, ROWS)
1776+ endif
1777+ break
1778+ default :
1779+ ASSERT ( 0, "Unsupported formulaLabel: " + formulaLabel)
1780+ break
1781+ endswitch
1782+
1783+ // fallback to the unit if present
1784+ if ( ! IsEmpty ( unit))
1785+ axisLabels[ size] = SF_FormatUnit ( unit)
1786+ size += 1
1787+ endif
17661788 endfor
17671789
17681790 Redimension / N= ( size) axisLabels
@@ -1856,7 +1878,7 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode
18561878 variable winDisplayMode, showLegend, tagCounter, overrideMarker
18571879 variable xMxN, yMxN, xPoints, yPoints, keepUserSelection, numAnnotations, formulasAreDifferent, postPlotPSX
18581880 variable formulaCounter, gdIndex, markerCode, lineCode, lineStyle, traceToFront, isCategoryAxis
1859- string win, wList, winNameTemplate, exWList, wName, annotation, yAxisLabel, wvName, info, xAxis
1881+ string win, wList, winNameTemplate, exWList, wName, annotation, xAxisLabel , yAxisLabel, wvName, info, xAxis
18601882 string formulasRemain, yAndXFormula, xFormula, yFormula, tagText, name, winHook
18611883 STRUCT SF_PlotMetaData plotMetaData
18621884 STRUCT RGBColor color
@@ -1886,7 +1908,7 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode
18861908 formulaCounter = 0
18871909 WAVE /Z wvX = $ ""
18881910
1889- Make / FREE/ T/ N=0 yAxisLabels
1911+ Make / FREE/ T/ N=0 xAxisLabels , yAxisLabels
18901912
18911913 formulasRemain = graphCode[ j]
18921914
@@ -1918,7 +1940,8 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode
19181940 Abort
19191941 endtry
19201942
1921- SF_GatherAxisLabels ( formulaResults, plotMetaData. yAxisLabel, yAxisLabels)
1943+ SF_GatherAxisLabels ( formulaResults, plotMetaData. xAxisLabel, "FORMULAX" , xAxisLabels)
1944+ SF_GatherAxisLabels ( formulaResults, plotMetaData. yAxisLabel, "FORMULAY" , yAxisLabels)
19221945
19231946 if ( ! cmpstr ( plotMetaData. dataType, SF_DATATYPE_PSX))
19241947 PSX_Plot ( win, graph, formulaResults, plotMetaData)
@@ -2249,8 +2272,9 @@ static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode
22492272 endfor
22502273
22512274 if ( traceCnt > 0 )
2252- if ( ! IsEmpty ( plotMetaData. xAxisLabel))
2253- Label / W=$ win bottom, plotMetaData. xAxisLabel
2275+ xAxisLabel = SF_CombineAxisLabels ( xAxisLabels)
2276+ if ( ! IsEmpty ( xAxisLabel))
2277+ Label / W=$ win bottom, xAxisLabel
22542278 ModifyGraph / W=$ win tickUnit ( bottom) =1
22552279 endif
22562280
0 commit comments