
Using strings as axisname while using AppendToGraph

ankit7540
When working with small number of waves, the AppendToGraph command with literal axis name works fine, or we can just use the GUI.
For example,
AppendToGraph /B=B1 wave0
However, I am trying to achieve this in a procedure where I can plot multiple waves automatically.
I generate the 'axisname' which is stored in a string, and I want to pass this to
AppendToGraph
; something like AppendToGraph /B=(stringVariable) wave0
I get error "ill formed name".
Alternatively, I tried storing the axisnames in text wave and then pass the axisname in a loop to iteratively append to the graph. This also did not work.
Any suggestions. (Following is a procedure which explains what I am trying.)
// Function to plot multiple waves on different axes and modify them on the fly. function autoPlot_test() // This is for testing hence waves are generated herein! // Generate 4 waves here make /o/d /n=200 f1=sin(p/0.01) make /o/d /n=200 f2=sin(p/0.05) make /o/d /n=200 f3=cos(p/0.01) make /o/d /n=200 f4=cos(p/0.05) wave f1=f1 variable i variable x1=4 string wname string axis // display the first plot display f1 // axisname becomes 'left / bottom' // make text wave for axis names make /o /T /n=(x1) axisLabel // make wave for axis intervals make /o /n=(x1) intMin, intMax wave /T axisLabel = axisLabel wave intMin = intMin wave intMax = intMax // Axis label axisLabel[0] = "bottom" // first value // Axis intervals, 4 intervals for 4 waves intMin[0]=0 ; intMax[0]=0.22 intMin[1]=0.25 ; intMax[1]=0.47 intMin[2]=0.5 ; intMax[2]=0.77 intMin[3]=.79 ; intMax[3]=1.0 // Loop for appending to plot for (i=1 ; i<x1 ; i=i+1) sprintf wname, "f%g", i sprintf axis , "a%g",i wave w0=$wname axisLabel[i] = axis print nameofwave(w0), axis, intMin(i), intMax(i) // Want to split into three sections horizontally with three waves ----- AppendToGraph /B=(axis) w0 // remove the paranthesis around (axis) to compile // AppendToGraph /B=[(axisLabel[i])] w0 ModifyGraph axisEnab(axis) = { intMin(i), intMax(i) } // ModifyGraph freePos(axis)=0 // -------------------------------------------------------------------------- endfor end
literal
and not astring
.This means, that you would have to deref the string:
$s_string
.So this ought to work:
best,
_sk
May 1, 2018 at 01:42 am - Permalink
I need to read about literal strings !
-Ankit
May 1, 2018 at 03:29 am - Permalink